Files
Morgan Pretty 0df6501265 Pushing up my WIP changes from the last few days
Got a number of the GroupUpdate messages working properly
Updated the DisplayPictureDownloadJob to support OpenGroup room images
Updated the Poller to process messages by namespace (sorted) and added support for synchronous handling of messages
Reworked the ProfileManager to be a more reusable DisplayPictureManager
Cleaned up the conversion from milliseconds to TimeInterval (which is documented as seconds) for clarity
Fixed a read/write crash due to the SnodeAPI cache setup
Fixed an issue where dependencies could incorrectly overwrite each other when based on protocols
2023-10-19 18:02:12 +11:00

38 lines
894 B
Swift

// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
import Foundation
// MARK: - Singleton
public class Singleton {}
// MARK: - SingletonConfig<S>
public class SingletonConfig<S>: Singleton {
public let identifier: String
public let createInstance: (Dependencies) -> S
/// `fileprivate` to hide when accessing via `dependencies[singleton: ]`
fileprivate init(
identifier: String,
createInstance: @escaping (Dependencies) -> S
) {
self.identifier = identifier
self.createInstance = createInstance
}
}
// MARK: - Creation
public extension Dependencies {
static func create<S>(
identifier: String,
createInstance: @escaping (Dependencies) -> S
) -> SingletonConfig<S> {
return SingletonConfig(
identifier: identifier,
createInstance: createInstance
)
}
}