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.6.50 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.49 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.48 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.47 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.46 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.45 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.44 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.43 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.42 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.41 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.40 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.39 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.38 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb