|Pause a live query||Tobin Harris||11/3/12 6:24 AM|
I want my CouchLiveQuery to be paused when it's not the active screen in a navigation hierarchy, and then resume when the screen is loaded. This is to stop the query running and initiating re-indexing whilst the view is not visible.
Any ideas how to achieve this?
|Re: Pause a live query||Jens Alfke||11/3/12 12:32 PM|
Currently the best you can do is to dealloc the query object and re-create it the next time you need it. That’s probably awkward to do if you’ve got KV observers, though.
It would be pretty easy to add support for this to CouchLiveQuery — maybe a .paused property. While paused the object would ignore database-changed notifications except to set a flag remembering that one happened; when resumed, if the flag is set it’ll update immediately. Pull requests welcomed :)
(Even if you don’t implement this, it’d be great if you could file a CouchCocoa issue suggesting it.)
|Re: Pause a live query||Tobin Harris||11/3/12 4:34 PM|
The query object was an nstance variable, with state set by user interaction.
I ended up creating a copy of the query using asLiveQuery, an nil-ing the original.. I could then restart that query with correct state when the view appeared again. I'll update the bug db or implement a pause function when I et a mo!
|Re: Pause a live query||Tobin Harris||11/4/12 5:48 AM|
Have put this on the CouchCocoa issue list for now. I might get to fix it quite soon.