DS.Adapter#shouldBackgroundReloadRecord()

shouldBackgroundReloadRecord (store, snapshot) Boolean

Defined in addon/adapter.js:580
Available since 1.13.0

This method is used by the store to determine if the store should reload a record after the store.findRecord method resolves a cached record.

This method is only checked by the store when the store is returning a cached record.

If this method returns true the store will re-fetch a record from the adapter.

For example, if you do not want to fetch complex data over a mobile connection, or if the network is down, you can implement shouldBackgroundReloadRecord as follows:

shouldBackgroundReloadRecord: function(store, snapshot) {
  var connection = window.navigator.connection;
  if (connection === 'cellular' || connection === 'none') {
    return false;
  } else {
    return true;
  }
}

By default this hook returns true so the data for the record is updated in the background.

Parameters:

store DS.Store
snapshot DS.Snapshot

Returns:

Boolean
doc_EmberJs
2016-11-30 16:49:26
Comments
Leave a Comment

Please login to continue.