Class: Ruwi::App
- Inherits:
-
Object
- Object
- Ruwi::App
- Defined in:
- lib/ruwi/runtime/app.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(root_component, props) ⇒ App
constructor
A new instance of App.
- #mount(parent_el) ⇒ void
- #unmount ⇒ void
Constructor Details
#initialize(root_component, props) ⇒ App
Returns a new instance of App.
12 13 14 15 16 17 18 |
# File 'lib/ruwi/runtime/app.rb', line 12 def initialize(root_component, props) @root_component = root_component @props = props @parent_el = nil @is_mounted = false @vdom = nil end |
Class Method Details
.create(root_component, props = {}) ⇒ App
6 7 8 |
# File 'lib/ruwi/runtime/app.rb', line 6 def self.create(root_component, props = {}) new(root_component, props) end |
Instance Method Details
#mount(parent_el) ⇒ void
This method returns an undefined value.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ruwi/runtime/app.rb', line 22 def mount(parent_el) if @is_mounted raise "The application is already mounted" end @parent_el = parent_el @vdom = Ruwi::Vdom.h(@root_component, @props) Ruwi::Dom::MountDom.execute(@vdom, @parent_el) @is_mounted = true end |
#unmount ⇒ void
This method returns an undefined value.
35 36 37 38 39 40 41 42 |
# File 'lib/ruwi/runtime/app.rb', line 35 def unmount unless @is_mounted raise "The application is not mounted" end Ruwi::Dom::DestroyDom.execute(@vdom) reset end |