W3cubDocs

/Ember.js 4

Class SnapshotRecordArray

public
Defined in: ../packages/store/addon/-private/network/snapshot-record-array.ts:17
Module: @ember-data/store

snapshots Array public

Module: @ember-data/store
returns
Array
Array of snapshots

Get snapshots of the underlying record array

Example

app/adapters/post.js
import JSONAPIAdapter from '@ember-data/adapter/json-api';

export default class PostAdapter extends JSONAPIAdapter {
  shouldReloadAll(store, snapshotArray) {
    let snapshots = snapshotArray.snapshots();

    return snapshots.any(function(ticketSnapshot) {
      let timeDiff = moment().diff(ticketSnapshot.attr('lastAccessedAt'), 'minutes');
      if (timeDiff > 20) {
        return true;
      } else {
        return false;
      }
    });
  }
}

© 2022 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember-data/4.9/classes/SnapshotRecordArray/methods