Skip to content

Commit

Permalink
give manager a single designated init
Browse files Browse the repository at this point in the history
more behaviour to come in init, want it all in one place
  • Loading branch information
lawrence-forooghian committed Sep 26, 2024
1 parent 3e2b093 commit 0f7a58a
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions Sources/AblyChat/RoomLifecycleManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,40 @@ internal actor RoomLifecycleManager<Channel: RoomLifecycleContributorChannel> {
internal var channel: Channel
}

internal private(set) var current: RoomLifecycle = .initialized
internal private(set) var current: RoomLifecycle
internal private(set) var error: ARTErrorInfo?

private let logger: InternalLogger
private let clock: SimpleClock
private let contributors: [Contributor]

internal init(contributors: [Contributor], logger: InternalLogger, clock: SimpleClock) {
self.contributors = contributors
self.logger = logger
self.clock = clock
self.init(
current: .initialized,
contributors: contributors,
logger: logger,
clock: clock
)
}

#if DEBUG
internal init(testsOnly_current current: RoomLifecycle, contributors: [Contributor], logger: InternalLogger, clock: SimpleClock) {
self.current = current
self.contributors = contributors
self.logger = logger
self.clock = clock
self.init(
current: current,
contributors: contributors,
logger: logger,
clock: clock
)
}
#endif

private init(current: RoomLifecycle, contributors: [Contributor], logger: InternalLogger, clock: SimpleClock) {
self.current = current
self.contributors = contributors
self.logger = logger
self.clock = clock
}

// TODO: clean up old subscriptions (https://github.com/ably-labs/ably-chat-swift/issues/36)
private var subscriptions: [Subscription<RoomStatusChange>] = []

Expand Down

0 comments on commit 0f7a58a

Please sign in to comment.