Module: ServerComponentHelper

Included in:
ServerComponent::FetcherConfigurator
Defined in:
app/helpers/server_component_helper.rb

Defined Under Namespace

Classes: SetStateDSL

Instance Method Summary collapse

Instance Method Details

#set_state(jsrb) {|SetStateDSL.new(jsrb, new_state, prev_state)| ... } ⇒ Object

rubocop:disable Naming/AccessorMethodName

Yields:



25
26
27
28
29
30
# File 'app/helpers/server_component_helper.rb', line 25

def set_state(jsrb) # rubocop:disable Naming/AccessorMethodName
  new_state = jsrb.var! { {} }
  prev_state = jsrb.expr.component.state
  yield SetStateDSL.new(jsrb, new_state, prev_state)
  jsrb.do! jsrb.expr.component.setState.call(new_state)
end