You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
Some classes are inherently a singleton. One may forget to do .asSingleton() when configuring them currently. If we have a protocol called singleton which behaved similar to @Singleton annotation in java when used, we can make things better. This needs to be thought out a little more though since annotations in java and protocol conformance in swift have different semantics when it comes to inheritance, etc.
The text was updated successfully, but these errors were encountered:
It will essentially memoize the value. Without a singleton the init method will be called each time it is requested. It also makes it so the injected fields of the struct are always the same.
In normal swift, one can think about it being equivalent to
static let someSingleton = SomeStruct()
Versus
static var notASingleton: SomeStruct {
return SomeStruct()
}
Hi all (and @holmes), since this issue has been closed, I was wondering if it still makes sense to reference it in this repo's README?
From the "Scope Step" section:
In the future we may want to allow a class conforming to protocol (possibly named Singleton) to indicate that it should be bound as a singleton. It is tracked by this issue
Thanks!
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Some classes are inherently a singleton. One may forget to do
.asSingleton()
when configuring them currently. If we have a protocol called singleton which behaved similar to@Singleton
annotation in java when used, we can make things better. This needs to be thought out a little more though since annotations in java and protocol conformance in swift have different semantics when it comes to inheritance, etc.The text was updated successfully, but these errors were encountered: