Module: Isomorfeus

Defined in:
lib/isomorfeus/config.rb,
lib/isomorfeus/top_level.rb,
lib/isomorfeus/top_level_ssr.rb,
lib/isomorfeus/props/validator.rb,
lib/isomorfeus/react_view_helper.rb,
lib/isomorfeus/props/validate_hash_proxy.rb

Defined Under Namespace

Modules: Props, ReactViewHelper Classes: TopLevel

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.envObject

Returns the value of attribute env.



8
9
10
# File 'lib/isomorfeus/config.rb', line 8

def env
  @env
end

.initial_state_fetchedObject

Returns the value of attribute initial_state_fetched.



4
5
6
# File 'lib/isomorfeus/config.rb', line 4

def initial_state_fetched
  @initial_state_fetched
end

.initializedObject (readonly)

Returns the value of attribute initialized.



7
8
9
# File 'lib/isomorfeus/config.rb', line 7

def initialized
  @initialized
end

.server_side_renderingObject

Returns the value of attribute server_side_rendering.



102
103
104
# File 'lib/isomorfeus/config.rb', line 102

def server_side_rendering
  @server_side_rendering
end

.ssr_hot_asset_urlObject

Returns the value of attribute ssr_hot_asset_url.



103
104
105
# File 'lib/isomorfeus/config.rb', line 103

def ssr_hot_asset_url
  @ssr_hot_asset_url
end

.ssr_response_statusObject

Returns the value of attribute ssr_response_status.



6
7
8
# File 'lib/isomorfeus/config.rb', line 6

def ssr_response_status
  @ssr_response_status
end

.top_componentObject

Returns the value of attribute top_component.



5
6
7
# File 'lib/isomorfeus/config.rb', line 5

def top_component
  @top_component
end

.zeitwerkObject

Returns the value of attribute zeitwerk.



9
10
11
# File 'lib/isomorfeus/config.rb', line 9

def zeitwerk
  @zeitwerk
end

.zeitwerk_lockObject

Returns the value of attribute zeitwerk_lock.



106
107
108
# File 'lib/isomorfeus/config.rb', line 106

def zeitwerk_lock
  @zeitwerk_lock
end

Class Method Details

.add_client_init_class_name(init_class_name) ⇒ Object



27
28
29
# File 'lib/isomorfeus/config.rb', line 27

def add_client_init_class_name(init_class_name)
  client_init_class_names << init_class_name
end

.add_client_option(key, value = nil) ⇒ Object



31
32
33
34
# File 'lib/isomorfeus/config.rb', line 31

def add_client_option(key, value = nil)
  self.class.attr_accessor(key)
  self.send("#{key}=", value)
end

.cached_component_class(class_name) ⇒ Object

only used for SSR



42
43
44
45
# File 'lib/isomorfeus/config.rb', line 42

def cached_component_class(class_name)
  return cached_component_classes[class_name] if cached_component_classes.key?(class_name)
  cached_component_classes[class_name] = "::#{class_name}".constantize
end

.cached_component_classesObject

only used for SSR



37
38
39
# File 'lib/isomorfeus/config.rb', line 37

def cached_component_classes
  @cached_component_classes ||= {}
end

.configuration(&block) ⇒ Object



108
109
110
# File 'lib/isomorfeus/config.rb', line 108

def configuration(&block)
  block.call(self)
end

.development?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/isomorfeus/config.rb', line 60

def development?
  @development
end

.execute_init_classesObject



47
48
49
50
51
# File 'lib/isomorfeus/config.rb', line 47

def execute_init_classes
  client_init_class_names.each do |constant|
    constant.constantize.send(:init)
  end
end

.force_init!Object



18
19
20
21
22
23
24
25
# File 'lib/isomorfeus/config.rb', line 18

def force_init!
  unless Isomorfeus.initial_state_fetched
    Isomorfeus.initial_state_fetched = true
    Redux::Store.preloaded_state = Isomorfeus.store.get_state
  end
  Isomorfeus.force_init_store!
  execute_init_classes
end

.force_renderObject



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/isomorfeus/config.rb', line 80

def force_render
  begin
    if Isomorfeus.top_component
      ReactDOM.find_dom_node(Isomorfeus.top_component) # if not mounted will raise
      if `typeof Opal.global.deepForceUpdate === 'undefined'`
        Isomorfeus.top_component.JS.forceUpdate()
      else
        `Opal.global.deepForceUpdate(#{Isomorfeus.top_component})`
      end
    end
  rescue
    # TODO try mount first
    # if it fails
    `location.reload()` if on_browser?
  end
  nil
end

.initObject



11
12
13
14
15
16
# File 'lib/isomorfeus/config.rb', line 11

def init
  return if initialized
  @initialized = true
  Isomorfeus.init_store
  execute_init_classes
end

.production?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/isomorfeus/config.rb', line 64

def production?
  @production
end

.ssr_contextsObject



131
132
133
# File 'lib/isomorfeus/config.rb', line 131

def ssr_contexts
  @ssr_contexts ||= {}
end

.start_app!Object



72
73
74
75
76
77
78
# File 'lib/isomorfeus/config.rb', line 72

def start_app!
  if Isomorfeus.development? && Isomorfeus.on_browser?
    Isomorfeus.zeitwerk.enable_reloading
  end
  Isomorfeus.zeitwerk.setup
  Isomorfeus::TopLevel.mount!
end

.test?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/isomorfeus/config.rb', line 68

def test?
  @test
end

.versionObject



135
136
137
# File 'lib/isomorfeus/config.rb', line 135

def version
  Isomorfeus::VERSION
end