Class: Dommy::WakeLock
- Inherits:
-
Object
- Object
- Dommy::WakeLock
- Defined in:
- lib/dommy/navigator.rb
Overview
‘navigator.wakeLock` — Screen Wake Lock API stub. `request(type)` returns a Promise of a `WakeLockSentinel` whose `release()` flips `released` and dispatches a `release` event.
Instance Method Summary collapse
- #__js_call__(method, args) ⇒ Object
-
#initialize(window) ⇒ WakeLock
constructor
A new instance of WakeLock.
- #request(type = "screen") ⇒ Object
Constructor Details
#initialize(window) ⇒ WakeLock
Returns a new instance of WakeLock.
434 435 436 |
# File 'lib/dommy/navigator.rb', line 434 def initialize(window) @window = window end |
Instance Method Details
#__js_call__(method, args) ⇒ Object
442 443 444 445 446 447 |
# File 'lib/dommy/navigator.rb', line 442 def __js_call__(method, args) case method when "request" request(args[0] || "screen") end end |
#request(type = "screen") ⇒ Object
438 439 440 |
# File 'lib/dommy/navigator.rb', line 438 def request(type = "screen") PromiseValue.resolve(@window, WakeLockSentinel.new(@window, type.to_s)) end |