Sha256: d4af4e645b40150567b6381a930f85e1de3835a63e1387d9c4d1095db3bcfdb5

Contents?: true

Size: 419 Bytes

Versions: 5

Compression:

Stored size: 419 Bytes

Contents

module Ovto
  class PureComponent < Component
    class StateIsNotAvailable < StandardError; end

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

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

      @prev_props = args
      @cache = super
    end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ovto-0.7.0 lib/ovto/pure_component.rb
ovto-0.6.2 lib/ovto/pure_component.rb
ovto-0.6.1 lib/ovto/pure_component.rb
ovto-0.6.0 lib/ovto/pure_component.rb
ovto-0.6.0.rc1 lib/ovto/pure_component.rb