Factory 2.0 available in develop #61
Replies: 3 comments 6 replies
-
Here's a Factory 2.0 definition. extension Container {
var simpleService1: Factory<SimpleService> {
self { SimpleService() }
}
} We define the computed variable on our container, and then use a bit of syntactic sugar to ask the container to create our Factory for us. |
Beta Was this translation helpful? Give feedback.
-
Hi, Any thoughts as to when you think 2.0 might be released? Just looking to get some sort of feel as I am going to propose that we adopt Factory for a couple of projects at work and I want to do some prototyping to make the case. Thanks |
Beta Was this translation helpful? Give feedback.
-
I have an object that provides two different protocols and I am having difficulty getting it to work correctly with the graph scope. The underlying object itself should be a singleton so I thought the correct way to register it would be use the singleton scope modifier followed by the graph scope modifier. What I am finding at runtime though is that multiple instances of the object are being created when it is being accessed (through the injected property wrapper). Here's a snippet showing the setup. Any thoughts as to what I might be doing wrong here:
The AppStateEventService is the underlying object. I followed the example in the doc but the difference here is I need the instance to be a singleton. If I remove the graph scope and just leave singleton then I get the behavior I want. This is similar to how I accomplished a singleton object that returns multiple protocols in Factory 1.0. Just thought that with 2.0 I should somehow be putting the graph scope to use in this scenario. Any details you can provide on this are appreciated. Thx |
Beta Was this translation helpful? Give feedback.
-
As mentioned earlier, Factory 2.0 is under development and will be released shortly. If you're brave, or just curious, you can access the develop branch today and check it out.
At the moment it passes all of the existing unit test and feels pretty solid, so it should be relatively safe to play with. Keep in mind that it's a breaking change from 1.0, so make sure to read the README.
There's a lot of DocC documentation available, with more coming, so stay tuned.
Beta Was this translation helpful? Give feedback.
All reactions