Sha256: 3f3e0fba5c8856879faedd5a3b650f6ae941f61ae9dad8d6f8c1d75777db7e1f

Contents?: true

Size: 552 Bytes

Versions: 2

Compression:

Stored size: 552 Bytes

Contents

module Inesita
  module Component
    include VirtualDOM

    def mount(element)
      @virtual_dom = NodeFactory.new(method(:render), self).nodes.first
      @mount_point = VirtualDOM.create(@virtual_dom)
      element.inner_dom = @mount_point
    end

    def update
      return unless @virtual_dom && @mount_point
      new_virtual_dom =  NodeFactory.new(method(:render), self).nodes.first
      diff = VirtualDOM.diff(@virtual_dom, new_virtual_dom)
      VirtualDOM.patch(@mount_point, diff)
      @virtual_dom = new_virtual_dom
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
inesita-0.0.2 opal/inesita/component.rb
inesita-0.0.1 opal/inesita/component.rb