Sha256: c6d5b0c91bd5671932e7ff4324ce631688c8e834605b40b31928cc3a07e58720
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
require 'react/component' module Hyperloop module Vis module Network module Mixin def self.included(base) base.include(Hyperloop::Component::Mixin) base.class_eval do param data: nil param options: nil def _set_dom_node(dom_node) @_dom_node = dom_node end def data @_data end def document `window.document` end def options @_options end def self.render_with_dom_node(tag = 'DIV', &block) render do @_vis_render_block = block @_data = params.data @_options = params.options send(tag, ref: method(:_set_dom_node).to_proc) end end def should_component_update? false end after_mount do if @_dom_node && @_vis_render_block @_vis_render_block.call(@_dom_node, @_data, @_options) end end before_receive_props do |new_props| changed = false if new_props[:data] != @_data @_data = new_props[:data] changed = true end if new_props[:options] != @_options @_options = new_props[:options] changed = true end if changed && @_dom_node && @_vis_render_block @_vis_render_block.call(@_dom_node, @_data, @_options) end end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hyper-vis-1.0.0.lap26 | lib/hyperloop/vis/network/mixin.rb |