Class: Backlex::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/backlex/realtime.rb

Overview

Handle for an active realtime subscription. #close unsubscribes — the same contract as the TS SDK’s returned unsubscribe function. The reader runs on a background thread and auto-reconnects on a dropped stream (3s back-off), replaying via Last-Event-ID.

Instance Method Summary collapse

Constructor Details

#initialize(client, url, on_event, on_error) ⇒ Subscription

Returns a new instance of Subscription.



13
14
15
16
# File 'lib/backlex/realtime.rb', line 13

def initialize(client, url, on_event, on_error)
  @stopped = false
  @thread = Thread.new { run(client, url, on_event, on_error) }
end

Instance Method Details

#closeObject



18
19
20
21
# File 'lib/backlex/realtime.rb', line 18

def close
  @stopped = true
  @thread&.kill
end