class AppStore

Public Class Methods

[](key, *args, &block)
Alias for: method_missing
[]=(key, *args, &block)
Alias for: method_missing
get(key, *args, &block)
Alias for: method_missing
method_missing(key, *args, &block) click to toggle source
# File lib/app_store.rb, line 3
def method_missing(key, *args, &block)
  if `args.length > 0`
    # set class state, simply a dispatch
    action = { type: 'APPLICATION_STATE', name: (`key.endsWith('=')` ? key.chop : key), value: args[0] }
    Isomorfeus.store.collect_and_defer_dispatch(action)
  else
    # check store for value
    a_state = Isomorfeus.store.get_state
    if a_state.key?(:application_state) && a_state[:application_state].key?(key)
      return a_state[:application_state][key]
    end

    # otherwise return nil
    return nil
  end
end
Also aliased as: [], []=, get, set
promise_get(key) click to toggle source
# File lib/app_store.rb, line 26
def promise_get(key)
  Promise.new.resolve(get(key))
end
promise_set(key, value) click to toggle source
# File lib/app_store.rb, line 30
def promise_set(key, value)
  Promise.new.resolve(set(key, value))
end
set(key, *args, &block)
Alias for: method_missing
subscribe(&block) click to toggle source
# File lib/app_store.rb, line 34
def subscribe(&block)
  Isomorfeus.store.subscribe(&block)
end
unsubscribe(unsubscriber) click to toggle source
# File lib/app_store.rb, line 38
def unsubscribe(unsubscriber)
  `unsubscriber()`
end