Sha256: 5ca40304b33dce5acbae934adbc3074abe6690ed75f35e898b7cd122f43b123e

Contents?: true

Size: 887 Bytes

Versions: 33

Compression:

Stored size: 887 Bytes

Contents

module LucidComponent
  class AppStoreProxy
    def initialize(native)
      @native = native
    end

    def [](key)
      method_missing(key)
    end

    def []=(key, value)
      method_missing(key, value)
    end

    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 if we have a component local state value
        if `#@native?.props?.iso_store?.application_state?.hasOwnProperty?.(key)`
          return `#@native.props.iso_store.application_state[key]`
        else
          return AppStore[key]
        end
        # otherwise return nil
        return nil
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
isomorfeus-preact-10.9.0 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.8.2 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.8.1 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.8.0 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.7.3 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.7.2 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.7.1 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.7.0 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.62 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.61 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.60 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.59 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.58 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.57 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.56 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.55 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.54 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.53 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.52 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.51 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb