I've added an option to a library 
<https://github.com/adamski/react-native-couchbase> I'm using to replicate 
on a background thread.  

The relevant code:

[manager backgroundTellDatabaseNamed:databaseLocal to:^(CBLDatabase *bgdb)
{
 NSLog(@"Starting pull on background thread...");
 // Inside this block we can't use `db`; instead use the instance given (`bgdb`)
 [self startPull:bgdb
 withRemoteUrl:remoteUrl
 withRemoteUser:remoteUser
 withRemotePassword:remotePassword
 withEvents:events
 withOptions:options];

 // Required in order to listen to events
 [[NSRunLoop currentRunLoop] run];
}];

`startPull` contains:


CBLReplication* pull = [db createPullReplication: url];//...
[pulls setObject:pull forKey:db.name];
// Add the events handler.
if (events) {
 [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handleReplicationEvent:) 
name:kCBLReplicationChangeNotification object:pull];
}
[pull start];


(Full code is here 
<https://github.com/adamski/react-native-couchbase/blob/master/ios/RCTCouchBase/RCTCouchBase/RCTCouchBase.m>)


The notifications work fine when the method is called from outside the 
backgroundTellDatabaseNamed block. I add the `[[NSRunLoop currentRunLoop] run]` 
line but that does not seem to have got it working. 


Anything I've missed or need to consider to get notifications when replicating 
in the backgroundTellDatabaseNamed block?


-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mobile-couchbase+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/0765bddd-d087-48de-81a6-15f0f1683519%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to