class React::IsomorphicHelpers::Context
Attributes
controller[R]
unique_id[R]
Public Class Methods
before_first_mount_blocks()
click to toggle source
# File lib/reactive-ruby/isomorphic_helpers.rb, line 88 def self.before_first_mount_blocks @before_first_mount_blocks ||= [] end
new(unique_id, ctx = nil, controller = nil, name = nil)
click to toggle source
# File lib/reactive-ruby/isomorphic_helpers.rb, line 96 def initialize(unique_id, ctx = nil, controller = nil, name = nil) @unique_id = unique_id if RUBY_ENGINE != 'opal' @controller = controller @ctx = ctx ctx["ServerSideIsomorphicMethods"] = self send_to_opal(:load_context, @unique_id, name) end self.class.before_first_mount_blocks.each { |block| block.call(self) } end
register_before_first_mount_block(&block)
click to toggle source
# File lib/reactive-ruby/isomorphic_helpers.rb, line 118 def self.register_before_first_mount_block(&block) before_first_mount_blocks << block end
Public Instance Methods
eval(js)
click to toggle source
# File lib/reactive-ruby/isomorphic_helpers.rb, line 107 def eval(js) @ctx.eval(js) if @ctx end
send_to_opal(method, *args)
click to toggle source
# File lib/reactive-ruby/isomorphic_helpers.rb, line 111 def send_to_opal(method, *args) return unless @ctx args = [1] if args.length == 0 ::ReactiveRuby::ComponentLoader.new(@ctx).load! @ctx.eval("Opal.React.IsomorphicHelpers.$#{method}(#{args.collect { |arg| "'#{arg}'"}.join(', ')})") end