Class: Scarpe::WASMDisplayService
- Inherits:
-
Shoes::DisplayService
- Object
- Shoes::DisplayService
- Scarpe::WASMDisplayService
- Includes:
- Shoes::Log
- Defined in:
- lib/scarpe/wasm/wasm_local_display.rb
Overview
This is the simplest type of WASM DisplayService. It creates WASM widgets corresponding to Shoes widgets, manages the WASM and its DOM tree, and generally keeps the Shoes/WASM connection working.
This is an in-process WASM-based display service, with all the limitations that entails. Slow handlers will crash, ending this display service will end the process, too many or too large evals can crash the process, etc. Frequently it’s better to use a RelayDisplayService to a second process containing one of these.
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
app is the Scarpe::WASMApp.
-
#control_interface ⇒ Object
readonly
The ControlInterface is used to handle internal events in WASM Scarpe.
-
#doc_root ⇒ Object
readonly
The DocumentRoot is the top widget of the WASM-side widget tree.
-
#wrangler ⇒ Object
readonly
wrangler is the Scarpe::WebWrangler.
Instance Method Summary collapse
-
#create_display_widget_for(widget_class_name, widget_id, properties) ⇒ WASMWidget
Create a WASM display widget for a specific Shoes widget, and pair it with the linkable ID for this Shoes widget.
-
#destroy ⇒ void
Destroy the display service and the app.
-
#initialize ⇒ WASMDisplayService
constructor
This is called before any of the various WASMWidgets are created, to be able to create them and look them up.
Constructor Details
#initialize ⇒ WASMDisplayService
This is called before any of the various WASMWidgets are created, to be able to create them and look them up.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/scarpe/wasm/wasm_local_display.rb', line 34 def initialize if WASMDisplayService.instance raise "ERROR! This is meant to be a singleton!" end WASMDisplayService.instance = self super() log_init("WASM::WASMDisplayService") @display_widget_for = {} end |
Class Attribute Details
.instance ⇒ Object
Returns the value of attribute instance.
17 18 19 |
# File 'lib/scarpe/wasm/wasm_local_display.rb', line 17 def instance @instance end |
Instance Attribute Details
#app ⇒ Object (readonly)
app is the Scarpe::WASMApp
27 28 29 |
# File 'lib/scarpe/wasm/wasm_local_display.rb', line 27 def app @app end |
#control_interface ⇒ Object (readonly)
The ControlInterface is used to handle internal events in WASM Scarpe
21 22 23 |
# File 'lib/scarpe/wasm/wasm_local_display.rb', line 21 def control_interface @control_interface end |
#doc_root ⇒ Object (readonly)
The DocumentRoot is the top widget of the WASM-side widget tree
24 25 26 |
# File 'lib/scarpe/wasm/wasm_local_display.rb', line 24 def doc_root @doc_root end |
#wrangler ⇒ Object (readonly)
wrangler is the Scarpe::WebWrangler
30 31 32 |
# File 'lib/scarpe/wasm/wasm_local_display.rb', line 30 def wrangler @wrangler end |
Instance Method Details
#create_display_widget_for(widget_class_name, widget_id, properties) ⇒ WASMWidget
Create a WASM display widget for a specific Shoes widget, and pair it with the linkable ID for this Shoes widget.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/scarpe/wasm/wasm_local_display.rb', line 54 def (, , properties) if == "App" unless @doc_root raise "WASMDocumentRoot is supposed to be created before WASMApp!" end display_app = Scarpe::WASMApp.new(properties) display_app.document_root = @doc_root @control_interface = display_app.control_interface @control_interface.doc_root = @doc_root @app = @control_interface.app @wrangler = @control_interface.wrangler (, display_app) return display_app end # Create a corresponding display widget display_class = Scarpe::WASMWidget.display_class_for() = display_class.new(properties) (, ) if == "DocumentRoot" # WASMDocumentRoot is created before WASMApp. Mostly doc_root is just like any other widget, # but we'll want a reference to it when we create WASMApp. @doc_root = end end |
#destroy ⇒ void
This method returns an undefined value.
Destroy the display service and the app. Quit the process (eventually.)
89 90 91 92 |
# File 'lib/scarpe/wasm/wasm_local_display.rb', line 89 def destroy @app.destroy WASMDisplayService.instance = nil end |