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 81
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 89
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 111
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 100
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 104
def send_to_opal(method, *args)
  return unless @ctx
  args = [1] if args.length == 0
  ::ReactiveRuby::ComponentLoader.new(@ctx).load!
  @ctx.eval("Opal.React.$const_get('IsomorphicHelpers').$#{method}(#{args.collect { |arg| "'#{arg}'"}.join(', ')})")
end