Class: InstantRecord::Client::Notifier::JsClients
- Inherits:
-
Object
- Object
- InstantRecord::Client::Notifier::JsClients
- Defined in:
- lib/instant_record/client/notifier.rb
Overview
Tells every open tab that local data changed so pages re-render. Runs in the service worker context; indexes the client list rather than passing Ruby procs to JS (narrower interop surface).
Instance Method Summary collapse
-
#initialize ⇒ JsClients
constructor
A new instance of JsClients.
- #records_changed ⇒ Object
Constructor Details
#initialize ⇒ JsClients
Returns a new instance of JsClients.
8 9 10 |
# File 'lib/instant_record/client/notifier.rb', line 8 def initialize require "js" end |
Instance Method Details
#records_changed ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/instant_record/client/notifier.rb', line 12 def records_changed clients = JS.global[:clients].matchAll.await = JS.eval("return {type: 'records_changed'}") clients[:length].to_i.times do |i| clients[i].postMessage() end end |