Skip to content
Discussion options

You must be logged in to vote

I've figured that one out. Just for the record, it was something like that.

On the Objective-C side:

 - (id) init {
   if (self = [super init]) {
    storage = [NativeLocalStorage new];
    [storage setEmitOnKeyAdded:^(NSString *key, NSString *value){
      [self emitOnKeyAdded:@{@"key": key, @"value": value}];
    }];
   }
   return self;
 }

On the Swift side:

  var emitOnKeyAdded: ((NSString, NSString?) -> ())? = nil
  
  func setEmitOnKeyAdded(emitOnKeyAdded: @escaping (NSString, NSString?) -> ()) {
    self.emitOnKeyAdded = emitOnKeyAdded
  }

And then the autogenerated emit method can be accessed from the Swift code.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by icedevml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants