Comments (5)
Yep. That's a fairly specific bug in regard to singletons in SharedContainer being resolved across multiple container instances and multiple container classes. I'll look into it.
At this point in time defaultScope is container-based. Any resolution from a container uses that container's default scope.
Your best bet there is simply to mark the service with .singleton.
from factory.
I tried add .singleton to service in SharedContainer but it still inits twice. Behaviour stayed the same.
from factory.
As mentioned this is a bug.
The "Your best bet there is simply to mark the service with .singleton." is the answer to the second question you asked. Since "SharedContainer" is virtual, there's no associated defaultScope, so each definition would need to marked as singleton.
That approach, however, won't work until the bug is fixed for this specific use case.
from factory.
It's not an official release yet, but you can pull the main branch and see if this corrects the problem.
from factory.
Yes, it's helped, service init one time thank you
from factory.
Related Issues (20)
- @InjectedLazyObject HOT 1
- Multiple previews and resolving different values for a singleton HOT 1
- 2.3 no longer works on linux - missing os_unfair_lock HOT 3
- Some minor suggestions and issues. HOT 6
- UnitTesting Cached Service Issue/Question HOT 3
- Resetting instance variables on long lived object when resetting scope HOT 5
- very heavy load on the CPU HOT 9
- Cannot build XCFramework HOT 1
- Missing Registeration in Multi Module HOT 1
- Name spacing conflict HOT 4
- Are you interested for macro ? HOT 2
- Can not build app for deivce ios 15 when import Factory HOT 5
- complete Swift Concurrency Checking: "Reference to class property 'shared' is not concurrency-safe because it involves shared mutable state" HOT 1
- Using Factory in a Sendable conforming Class HOT 1
- UITests LaunchArguments Failing in Headless Mode HOT 1
- What is diffrence between this framework and singleton pattern? HOT 1
- Building xcframework on Xcode 15.0 HOT 13
- Support @Bindable with @Injected property wrappers HOT 3
- is it possible to inject swiftui view through factory? HOT 1
- Privacy manifest file HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from factory.