Triggering a CBLLiveQuery to re-run without changing the data

19 views
Skip to first unread message

Sebastien ARBOGAST

unread,
Jan 5, 2015, 12:57:28 PM1/5/15
to mobile-c...@googlegroups.com
I have a tableview listing documents based on whether one of their date properties is in the past or the future. So whenever one of the document has its date that reaches now, I need to refresh my table. I have the event handler that is triggered when one of the rows reaches that point in time, but is there any way that I can ask it to trigger a re-run of the live query, as if one of the documents was changed?

Best regards,
---
Sébastien Arbogast
http://sebastien-arbogast.com

Jens Alfke

unread,
Jan 5, 2015, 5:31:24 PM1/5/15
to mobile-c...@googlegroups.com

On Jan 5, 2015, at 9:57 AM, Sebastien ARBOGAST <sebastien...@gmail.com> wrote:

I have a tableview listing documents based on whether one of their date properties is in the past or the future. So whenever one of the document has its date that reaches now, I need to refresh my table. I have the event handler that is triggered when one of the rows reaches that point in time, but is there any way that I can ask it to trigger a re-run of the live query, as if one of the documents was changed?

Why? It sounds like you just need to tell the table view to redraw.

—Jens

Sebastien ARBOGAST

unread,
Jan 5, 2015, 6:18:12 PM1/5/15
to mobile-c...@googlegroups.com
I forgot to mention that the tableview draws its data from a CBLLiveQuery on a view, so my understanding was that if no document is changed, then the view is not reindexed and the livequery is not run again. So I guess the more correct question would be is there a way to force a view to be remapped?

---
Sébastien Arbogast
http://sebastien-arbogast.com

--
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-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/972F725C-A354-4EB7-A85B-51537F02D055%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Jens Alfke

unread,
Jan 5, 2015, 6:32:22 PM1/5/15
to mobile-c...@googlegroups.com

On Jan 5, 2015, at 3:17 PM, Sebastien ARBOGAST <sebastien...@gmail.com> wrote:

I forgot to mention that the tableview draws its data from a CBLLiveQuery on a view, so my understanding was that if no document is changed, then the view is not reindexed and the livequery is not run again. So I guess the more correct question would be is there a way to force a view to be remapped?

I'm confused. You want to change the map function of the view? Why?

(I hope you don't have a map function that's doing comparisons against the current date. That's illegal. The map function has to be a pure function that always produces the same output given the same input. The current date has a different value on every run, so it violates that.)

—Jens

Sebastien ARBOGAST

unread,
Jan 5, 2015, 6:34:13 PM1/5/15
to mobile-c...@googlegroups.com
So I'm doing something illegal indeed. Thanks for reminding me of that. I need to change that. And that answers my question.

---
Sébastien Arbogast
http://sebastien-arbogast.com

--
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-couchba...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages