Sha256: 18b3bba35209ee9b2aeb5e4ab93138eaeccfde073fce6bfecbb97d50d70c3463

Contents?: true

Size: 1.11 KB

Versions: 50

Compression:

Stored size: 1.11 KB

Contents

module LucidComponent
  class AppStoreProxy
    def initialize(component_instance)
      if component_instance
        @native = component_instance.to_n
        @component_instance = component_instance
      end
    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 && `#@native.props.iso_store`
          if `#@native.props.iso_store.application_state && #@native.props.iso_store.application_state.hasOwnProperty(key)`
            return @native.JS[:props].JS[:iso_store].JS[:application_state].JS[key]
          end
        else
          return AppStore[key]
        end
        # otherwise return nil
        return nil
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
isomorfeus-preact-10.6.37 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.36 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.35 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.34 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.33 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.32 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.31 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.30 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.29 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.28 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.27 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.26 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.25 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.24 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.23 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.22 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.21 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.20 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.19 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb
isomorfeus-preact-10.6.18 lib/isomorfeus_preact/lucid_component/app_store_proxy.rb