Watermelondb: watermelon update not triggering observable

Created on 25 Mar 2019  Â·  7Comments  Â·  Source: Nozbe/WatermelonDB

I'm running into an issue where I have 2 screens in react-native.

I'm observing the changes to this collection on a list view screen, and preforming item creation/updates on the second screen. Any creation that occurs is reflected on the list view, however when I preform an update to an item it doesn't reflect on the list view. I'm at a loss currently and if there's any more information/clarity I could provide please let me know.

```
const Screen = withDatabase(
withObservables([], ({ database }) => ({
games: database.collections
.get('games')
.query()
.observe(),
}))(SummaryListScreen)
);

Most helpful comment

@mikebeyer You confuse two similar, but also very different things — observing a model/record (like Post in the quoted example), and observing a query (a list of things).

Note https://github.com/Nozbe/WatermelonDB/blob/master/docs/Components.md#reactive-lists :

However, observing the comments Query will not re-render if a comment is updated — we render the so that it observes the comment and re-renders if necessary.

Observing list re-renders the list if necessary — but each item should individually observe its corresponding record as well

All 7 comments

this is working as designed — explained here:
https://github.com/Nozbe/WatermelonDB/blob/master/docs/Components.md

@radex
Like before, we enhance it by observing the Post. If the post name or body changes, it will re-render. I read over the linked docs and I'm missing where an update won't cause a re-render.

Or does this have to do with the component within the list itself not observing its own changes.

@mikebeyer You confuse two similar, but also very different things — observing a model/record (like Post in the quoted example), and observing a query (a list of things).

Note https://github.com/Nozbe/WatermelonDB/blob/master/docs/Components.md#reactive-lists :

However, observing the comments Query will not re-render if a comment is updated — we render the so that it observes the comment and re-renders if necessary.

Observing list re-renders the list if necessary — but each item should individually observe its corresponding record as well

Ah ha! That makes complete sense. Thanks!

this is working as designed — explained here:
https://github.com/Nozbe/WatermelonDB/blob/master/docs/Components.md

I have this issue but link not found

Gotten it thanks...

Was this page helpful?
0 / 5 - 0 ratings