Skip to content

Commit

Permalink
Use eventSubject on AirshipProxyEmitter
Browse files Browse the repository at this point in the history
  • Loading branch information
crow committed Nov 27, 2023
1 parent 78fed6d commit d4eb775
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions ios/Classes/SwiftAirshipPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public class SwiftAirshipPlugin: NSObject, FlutterPlugin {
.notificationStatusChanged: "com.airship.flutter/event/notification_status_changed"
]


private static let eventSubject = PassthroughSubject<AirshipProxyEventType, Never>()

private let streams: [AirshipProxyEventType: AirshipEventStream] = {
var streams: [AirshipProxyEventType: AirshipEventStream] = [:]
SwiftAirshipPlugin.eventNames.forEach { (key: AirshipProxyEventType, value: String) in
Expand All @@ -31,7 +28,6 @@ public class SwiftAirshipPlugin: NSObject, FlutterPlugin {

private var subscriptions = Set<AnyCancellable>()


public static func register(with registrar: FlutterPluginRegistrar) {
SwiftAirshipPlugin().setup(registrar: registrar)
}
Expand All @@ -51,10 +47,11 @@ public class SwiftAirshipPlugin: NSObject, FlutterPlugin {
registrar.register(AirshipInboxMessageViewFactory(registrar), withId: "com.airship.flutter/InboxMessageView")
registrar.addApplicationDelegate(self)

SwiftAirshipPlugin.eventSubject.sink { [streams] eventType in
guard let stream = streams[eventType] else {
AirshipProxyEventEmitter.shared.eventSubject.sink { [weak self] (event: any AirshipProxyEvent) in
guard let self = self, let stream = self.streams[event.type] else {
return
}

Task {
await stream.processPendingEvents()
}
Expand Down

0 comments on commit d4eb775

Please sign in to comment.