Skip to content

Instantly share code, notes, and snippets.

final class DidomiServiceProxy {
static let shared = DidomiServiceProxy()
private static let apiKey = "xxxxxxxxx"
private let service = Didomi.shared
init() {
service.onReady { [weak self] in
print("DIDOMI READY")
// 1. We need to define the screen "global" state
struct ParentState: Equatable {
var view1State: [String]
var view2State: Int
}
enum ParentActions {
case view1(View1Actions)
case view2(View2Actions)
@bitomule
bitomule / store.swift
Created February 28, 2020 08:40
Draft implementation of a Store in swift
public final class Store<Value: Equatable, Action> {
private let reducer: (inout Value, Action) -> Void
private var _observable: BehaviorSubject<Value>
public var observable: Observable<Value> {
get {
return _observable.distinctUntilChanged()
}
}
private var value: Value {
didSet {
@propertyWrapper
public struct Atomic<Value> {
private var value: Value
public init(wrappedValue: Value) {
self.value = wrappedValue
}
public var wrappedValue: Value {
_read {
final class ReplaySubscriber<Input, Failure: Error>: Subscription {
private var subscriber: AnySubscriber<Input, Failure>?
init(subscriber: AnySubscriber<Input, Failure>) {
self.subscriber = subscriber
}
func request(_ demand: Subscribers.Demand) {
// We do nothing here as we only want to send events when they occur.
// See, for more info: https://developer.apple.com/documentation/combine/subscribers/demand
### Keybase proof
I hereby claim:
* I am bitomule on github.
* I am bitomule (https://keybase.io/bitomule) on keybase.
* I have a public key ASAV0Ayu6kHVVmHJbtiLEnaqd0fnX7zVu92uC2Wk5umwZwo
To claim this, I am signing this object:
@bitomule
bitomule / gist:b766b264e79bf77386c1
Created March 26, 2015 08:16
Swfit NSDictionary Extension with helpers to parse ObjectiveDDP dictionaries
extension NSDictionary{
func getDateFromKey(key:String) -> NSNumber?{
if let date = (self.objectForKey(key) as? NSDictionary)?["$date"] as? NSNumber{
return date
}
return nil
}
func getFromKeyPath(keyPath:String)->AnyObject?{
let keysArray = split(keyPath) {$0 == "."}
Router.route('/uploadFile', {name:'uploadFile', where: 'server' })
.post(function(){
var request = this.request;
var response = this.response;
var buffers = [];
var totalLength = 0;
var fileUpload = Meteor.bindEnvironment(function(file){
Files.insert(file);
}, function(e) {
@bitomule
bitomule / gist:6fe5563e43031c06de3b
Created March 12, 2015 11:43
UploadToMeteor Controller
class UploadViewController: BaseViewController,NSURLSessionDelegate,NSURLSessionTaskDelegate,NSURLSessionDataDelegate {
var file:File?
var type:String = ""
var responseData = NSMutableData()
override func viewDidLoad() {
super.viewDidLoad()
let path = file!.getDownloadedPath()
var data: NSData = NSData(contentsOfURL: path)!
vats = {
ES:{
name:"España",
vat: 21
},
DE:{
name:"Germany",
vat: 19
},
AT:{