Sha256: ed7b69dd7c2528e6a15ba1318fbbfbde67d0882f6ef58fa961ac939e0427ed2d
Contents?: true
Size: 651 Bytes
Versions: 3
Compression:
Stored size: 651 Bytes
Contents
# StoreState provides method for a store to track its loading state. module StoreState # Called when a collection loads def loaded(initial_state=nil) change_state_to(initial_state || :not_loaded) end def state @state end # Called from the QueryListener when the data is loaded def change_state_to(new_state) @state = new_state # Trigger changed on the 'state' method @model.trigger_for_methods!('changed', :state, :loaded?) if @state == :loaded && @fetch_callbacks # Trigger each waiting fetch @fetch_callbacks.compact.each {|fc| fc.call(@model) } @fetch_callbacks = nil end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
volt-0.7.4 | lib/volt/models/persistors/store_state.rb |
volt-0.7.3 | lib/volt/models/persistors/store_state.rb |
volt-0.7.2 | lib/volt/models/persistors/store_state.rb |