Knowing if a pull is necessary

34 views
Skip to first unread message

Alan McKean

unread,
Feb 27, 2014, 6:17:36 PM2/27/14
to mobile-c...@googlegroups.com
I am starting a pull replication on app launch and I put up a progress indicator to show progress. I hide the progress indicator in my observer (observeValueForKeyPath:ofObject:change:context:). The first time I launch all goes well. The progress indicator hides when the last change comes in. However, when I launch a second time, I get no callbacks on the observer. I expect this is because there are no changes on the server so the pull does nothing. So the progress indicator never goes away. Is there a way to compare the lastSequence on the remote server with the lastSequence on the client app so that I can know whether or not to pull? Or is there a better way to know when the pull has completed, even if it did nothing due to no changes on the remote server?

Jens Alfke

unread,
Feb 27, 2014, 7:09:48 PM2/27/14
to mobile-c...@googlegroups.com

On Feb 27, 2014, at 3:17 PM, Alan McKean <alanm...@me.com> wrote:

I am starting a pull replication on app launch and I put up a progress indicator to show progress. I hide the progress indicator in my observer (observeValueForKeyPath:ofObject:change:context:). The first time I launch all goes well. The progress indicator hides when the last change comes in. However, when I launch a second time, I get no callbacks on the observer.

What property are you observing?

I’ve found that to display a progress UI you need to observe multiple properties. So I tend to use NSNotificationCenter instead to observe the kCBLReplicationChangeNotification. That way my observer gets called when any of the properties change.

Or is there a better way to know when the pull has completed, even if it did nothing due to no changes on the remote server?

Watch for the ‘status’ property to change to ‘idle’.

—Jens

Alan McKean

unread,
Feb 27, 2014, 7:20:14 PM2/27/14
to mobile-c...@googlegroups.com
I am watching the ‘completedChanges’ property. I’ll switch to watching the ‘status’ property.

--
You received this message because you are subscribed to a topic in the Google Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mobile-couchbase/6RCtOMsm5RY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/15330F58-A066-44C1-BA14-F2736D641AFA%40couchbase.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages