Class: Ovto::PureComponent

Inherits:
Component show all
Defined in:
lib/ovto/pure_component.rb

Defined Under Namespace

Classes: StateIsNotAvailable

Instance Method Summary collapse

Methods inherited from Component

hash_to_js_obj, middleware_name, #render

Constructor Details

#initialize(*args) ⇒ PureComponent

Returns a new instance of PureComponent.



5
6
7
8
9
# File 'lib/ovto/pure_component.rb', line 5

def initialize(*args)
  super
  @prev_props = nil
  @cache = nil
end

Instance Method Details

#do_render(args, state) ⇒ Object



11
12
13
14
15
16
# File 'lib/ovto/pure_component.rb', line 11

def do_render(args, state)
  return @cache if args == @prev_props

  @prev_props = args
  @cache = super
end

#stateObject



18
19
20
# File 'lib/ovto/pure_component.rb', line 18

def state
  raise StateIsNotAvailable, "Cannot use state in PureComponent"
end