SparseCollection.isPrepared(...)
Determine if a given set of models is available in the main thread. Returns true
if all the models are available,
or false
otherwise. Use it to determine if the models you need have already been prepared.
The method accepts the same aruments as prepare(...), allowing you to check specific IDs or specific indexes
// Check the first 100 (note 'max' is exclusive)
var prepared = collection.isPrepared({
indexes: { min: 0, max: 100 }
});
// Check one specific index
var prepared = collection.isPrepared({
index: 11
});
// Check specific IDs
var prepared = collection.isPrepared({
ids: [ 1, 2, 3, 4 ]
});
// Check one specific ID
var prepared = collection.isPrepared({
id: 5
});
If collection.isPrepared(...)
returns true
, then using the collection.get(id)
and collection.at(index)
methods
will work as expected. If it returns false
, those methods will throw Exceptions
for the referenced IDs or indexes.