client/lanes/models/Collection.coffee in lanes-0.1.8 vs client/lanes/models/Collection.coffee in lanes-0.1.9
- old
+ new
@@ -47,15 +47,19 @@
# Fetch the a set of models for the collection, replacing all
# current models whith them when the call completes
fetch: (options={})->
handlers = Lanes.Models.Sync.wrapRequest(this,options)
- this.sync('read', this, options)
+ if this.cacheDuration
+ Lanes.Models.ServerCache.fetchCollection(this, options)
+ else
+ this.sync('read', this, options)
handlers.promise
+
ensureLoaded: (options={})->
handlers = Lanes.Models.Sync.wrapRequest(this,options)
if options.force || (!@_isLoaded && !this.length )
- this.sync('read', this, options)
+ this.fetch(options)
else
handlers.resolvePromise( record: this, reply: {} )
handlers.promise
# Call the callback function when the current fetch succeeds