Class: Scarpe::WebviewDisplayService
- Inherits:
-
Shoes::DisplayService
- Object
- Shoes::DisplayService
- Scarpe::WebviewDisplayService
- Includes:
- Shoes::Log
- Defined in:
- lib/scarpe/wv/webview_local_display.rb
Overview
This is the simplest type of Webview DisplayService. It creates Webview widgets corresponding to Shoes widgets, manages the Webview and its DOM tree, and generally keeps the Shoes/Webview connection working.
This is an in-process Webview-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.
Constant Summary
Constants included from Shoes::Log
Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
app is the Scarpe::WebviewApp.
-
#control_interface ⇒ Object
readonly
The ControlInterface is used to handle internal events in Webview Scarpe.
-
#doc_root ⇒ Object
readonly
The DocumentRoot is the top widget of the Webview-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) ⇒ WebviewWidget
Create a Webview 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 ⇒ WebviewDisplayService
constructor
This is called before any of the various WebviewWidgets are created, to be able to create them and look them up.
Methods included from Shoes::Log
configure_logger, #log_init, logger
Methods inherited from Shoes::DisplayService
dispatch_event, display_service, full_reset!, #query_display_widget_for, set_display_service_class, #set_widget_pairing, subscribe_to_event, unsub_from_events
Constructor Details
#initialize ⇒ WebviewDisplayService
This is called before any of the various WebviewWidgets 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/wv/webview_local_display.rb', line 34 def initialize if WebviewDisplayService.instance raise "ERROR! This is meant to be a singleton!" end WebviewDisplayService.instance = self super() log_init("WV::WebviewDisplayService") = {} end |
Class Attribute Details
.instance ⇒ Object
Returns the value of attribute instance.
17 18 19 |
# File 'lib/scarpe/wv/webview_local_display.rb', line 17 def instance @instance end |
Instance Attribute Details
#app ⇒ Object (readonly)
app is the Scarpe::WebviewApp
27 28 29 |
# File 'lib/scarpe/wv/webview_local_display.rb', line 27 def app @app end |
#control_interface ⇒ Object (readonly)
The ControlInterface is used to handle internal events in Webview Scarpe
21 22 23 |
# File 'lib/scarpe/wv/webview_local_display.rb', line 21 def control_interface @control_interface end |
#doc_root ⇒ Object (readonly)
The DocumentRoot is the top widget of the Webview-side widget tree
24 25 26 |
# File 'lib/scarpe/wv/webview_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/wv/webview_local_display.rb', line 30 def wrangler @wrangler end |
Instance Method Details
#create_display_widget_for(widget_class_name, widget_id, properties) ⇒ WebviewWidget
Create a Webview 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/wv/webview_local_display.rb', line 54 def (, , properties) if == "App" unless @doc_root raise "WebviewDocumentRoot is supposed to be created before WebviewApp!" end display_app = Scarpe::WebviewApp.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::WebviewWidget.display_class_for() = display_class.new(properties) (, ) if == "DocumentRoot" # WebviewDocumentRoot is created before WebviewApp. Mostly doc_root is just like any other widget, # but we'll want a reference to it when we create WebviewApp. @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/wv/webview_local_display.rb', line 89 def destroy @app.destroy WebviewDisplayService.instance = nil end |