Skip to content

Commit

Permalink
fix(auth): auth event emitter being shared among clients (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev authored Aug 13, 2024
1 parent e58a817 commit 83f3385
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Sources/Auth/Internal/CodeVerifierStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ struct CodeVerifierStorage: Sendable {
}

extension CodeVerifierStorage {
static let live: Self = {
static var live: Self {
let code = LockIsolated(String?.none)

return Self(
get: { code.value },
set: { code.setValue($0) }
)
}()
}
}
2 changes: 1 addition & 1 deletion Sources/Auth/Internal/Dependencies.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct Dependencies: Sendable {
var sessionStorage: SessionStorage
var sessionManager: SessionManager

var eventEmitter: AuthStateChangeEventEmitter = .shared
var eventEmitter = AuthStateChangeEventEmitter()
var date: @Sendable () -> Date = { Date() }
var codeVerifierStorage = CodeVerifierStorage.live
var urlOpener: URLOpener = .live
Expand Down
4 changes: 1 addition & 3 deletions Sources/Auth/Internal/EventEmitter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import Foundation
import Helpers

struct AuthStateChangeEventEmitter {
static let shared = AuthStateChangeEventEmitter(emitter: .init(initialEvent: nil, emitsLastEventWhenAttaching: false))

let emitter: EventEmitter<(AuthChangeEvent, Session?)?>
var emitter = EventEmitter<(AuthChangeEvent, Session?)?>(initialEvent: nil, emitsLastEventWhenAttaching: false)

func attach(_ listener: @escaping AuthStateChangeListener) -> ObservationToken {
emitter.attach { event in
Expand Down

0 comments on commit 83f3385

Please sign in to comment.