Skip to content

Commit

Permalink
Do not emit events until JavaScript is ready
Browse files Browse the repository at this point in the history
If the synchronizer is running in the background, but the app does a hot-reload, we need to stop sending events until JavaScript is ready again.
  • Loading branch information
swansontec committed May 16, 2024
1 parent 52754e1 commit 576935b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- fixed: Pause synchronizer events until JavaScript is ready to receive them.

## 0.7.1 (2024-05-11)

- fixed: Stop depending on the iOS-provided SQLite, which causes crashes on iOS 13-15 because it is too old.
Expand Down
13 changes: 12 additions & 1 deletion ios/RNZcash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ let genericError = NSError(domain: "", code: 0)

@objc(RNZcash)
class RNZcash: RCTEventEmitter {
var hasListeners: Bool = false

override static func requiresMainQueueSetup() -> Bool {
return true
Expand Down Expand Up @@ -440,7 +441,17 @@ class RNZcash: RCTEventEmitter {

// Events
public func sendToJs(name: String, data: Any) {
self.sendEvent(withName: name, body: data)
if (hasListeners) {
self.sendEvent(withName: name, body: data)
}
}

override func startObserving() -> Void {
hasListeners = true
}

override func stopObserving() -> Void {
hasListeners = false
}

override func supportedEvents() -> [String] {
Expand Down

0 comments on commit 576935b

Please sign in to comment.