> On Dec 29, 2017, at 7:40 AM, Adam Wilson <[email protected]> wrote:
> 
> I've added an option to a library 
> <https://github.com/adamski/react-native-couchbase> I'm using to replicate on 
> a background thread.  

This isn’t necessary: replication already runs on a background thread. The 
CBLReplication class just sends messages to the background replicator and 
relays notifications from it, so all CBLReplication methods return immediately.

TL;DR: Just use CBLReplication on the main database; it’s asynchronous and 
won’t block your main thread.

There are a couple problems with the code you showed.
Using CBLReplication inside the background block probably won’t work, basically 
because the background database (`bgdb`) is itself the database instance that 
runs the real replicator work. Trying to predict what would happen is making my 
head hurt; simpler just to say Don’t do that.
The call to `[[NSRunLoop currentRunLoop] run]` will block forever, preventing 
the background database from handling any more requests. Don’t do that either :)

—Jens

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/A634A2CF-A942-4CA6-A0BD-47C3F0D6CC0B%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to