Sha256: ffc3b46bd9bf0408be3becd2f0b2bdeb543971c0747761761fac096de2357e52

Contents?: true

Size: 633 Bytes

Versions: 2

Compression:

Stored size: 633 Bytes

Contents

require 'opal'
require 'native'
require 'beryl/deserializer'
require 'beryl/frontend_runtime'

module Beryl
  class Frontend
    def initialize(view)
      @view = view
    end

    def onload(&block)
      `window.onload = block;`
    end

    def run
      onload do
        document = Native(`window.document`)
        root = document.getElementById('beryl')
        serialized_state = root.getAttribute('data-beryl').gsub('"', '"')
        state = Beryl::Deserializer.deserialize(serialized_state)
        puts "STATE = #{state.inspect}"
        Beryl::FrontendRuntime.new(root, state, @view).run
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
beryl-0.3.1 lib/beryl/frontend.rb
beryl-0.3.0 lib/beryl/frontend.rb