Module: ViewComponentReflex::Dom::Reflex

Defined in:
lib/view_component_reflex/dom/reflex.rb

Instance Method Summary collapse

Instance Method Details

#initial_stateObject



27
28
29
30
31
32
33
# File 'lib/view_component_reflex/dom/reflex.rb', line 27

def initial_state
  if element.dataset[:"#{key}_initial"]
    Verifier.verify(element.dataset[:"#{key}_initial"])
  else
    {}
  end
end

#inject_key_into_componentObject



20
21
22
23
24
25
# File 'lib/view_component_reflex/dom/reflex.rb', line 20

def inject_key_into_component
  super

  state_adapter.store_state(request, key, state)
  state_adapter.store_state(request, "#{key}_initial", initial_state)
end

#stateObject



12
13
14
15
16
17
18
# File 'lib/view_component_reflex/dom/reflex.rb', line 12

def state
  if element.dataset[:"#{key}_state"]
    Verifier.verify(element.dataset[:"#{key}_state"])
  else
    {}
  end
end