How does the ember knows the data base is being updated? I used the database of the first part of the guide. Thank you!
@FilipeFontes hello and welcome! The short answer is: it’s doesn’t know unless it asks.
The longer answer: Generally (and this is pretty standard across web technologies) APIs are client pull/poll which means the client is responsible for fetching the data that it needs (including refetching data it has already fetched). There are also server-push models where servers can update clients when a record has changed. AFAIK these are usually implemented with websockets. By default Ember Data uses pull to fetch data, and client data in Ember can be updated in a number of ways:
- refetching the data on an as-needed basis (this applies to any form of data fetching)
- refetching the data with a polling mechanism (just like #1 but done at a specific time interval)
- findRecord (applies only to Ember Data) will, by default, background reload a record that is already in the store. So once you request it from the store a second time it gives you what it has immediately but then updates it in the background
- notify the client cache (e.g. the store if using ember data) that a record has been updated from the server using something like websockets. Things like Firebase and some(/all?) graphql servers support this, and many choose to roll their own.
Anyway hope that helps.