Sha256: 824ba1b8e9b341c2134edb6293e71ee143337548cb9c66ef0e751f9f43fffa8a

Contents?: true

Size: 1.02 KB

Versions: 22

Compression:

Stored size: 1.02 KB

Contents

class AppStore
  class << self
    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

    alias [] method_missing
    alias []= method_missing

    alias get method_missing
    alias set method_missing

    def promise_get(key)
      Promise.new.resolve(get(key))
    end

    def promise_set(key, value)
      Promise.new.resolve(set(key, value))
    end

    def subscribe(&block)
      Isomorfeus.store.subscribe(&block)
    end

    def unsubscribe(unsubscriber)
      `unsubscriber()`
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
isomorfeus-redux-4.2.0 lib/app_store.rb
isomorfeus-redux-4.1.18 lib/app_store.rb
isomorfeus-redux-4.1.17 lib/app_store.rb
isomorfeus-redux-4.1.16 lib/app_store.rb
isomorfeus-redux-4.1.15 lib/app_store.rb
isomorfeus-redux-4.1.14 lib/app_store.rb
isomorfeus-redux-4.1.13 lib/app_store.rb
isomorfeus-redux-4.1.12 lib/app_store.rb
isomorfeus-redux-4.1.11 lib/app_store.rb
isomorfeus-redux-4.1.10 lib/app_store.rb
isomorfeus-redux-4.1.9 lib/app_store.rb
isomorfeus-redux-4.1.8 lib/app_store.rb
isomorfeus-redux-4.1.7 lib/app_store.rb
isomorfeus-redux-4.1.6 lib/app_store.rb
isomorfeus-redux-4.1.5 lib/app_store.rb
isomorfeus-redux-4.1.4 lib/app_store.rb
isomorfeus-redux-4.1.3 lib/app_store.rb
isomorfeus-redux-4.1.2 lib/app_store.rb
isomorfeus-redux-4.1.1 lib/app_store.rb
isomorfeus-redux-4.1.0 lib/app_store.rb