-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manually created assembly looses it's factory reference #551
Comments
Can you provide your usage code? |
|
For test purposes I've put [AppAssembly create] into viewDidLoad and inside this method everything works fine. But In the other method (button press callback) I can see reference to AppAssembly since it's retained, but fabric and assembly properties are nil. I'm using current version of Typhoon installed using Pods. |
When I checking assemblies created in PocketForecast sample app, I see that it has TyphoonBlockComponentFactory instance class. I'm really confused... |
Hi, @AlexeyPoldeo ! I think that the problem is in the way you are trying to use Typhoon.
When you create multiple assemblies manually (by calling
Well, this is possible but this approach doesn't belong to best practices. Consider assemblies as simple factories without any internal state. They are just proxies to access an underlying pool of created dependencies. |
With all my respect, but I see too many limitations in comparison to Dagger 2. Senior developers, who are smart enough to learn how to use Typhoon, do not need to put configuration to plist file to simplify their work. They want to get some tool to manage complicated object graphs and layer fabrics. |
@AlexeyPoldeo If you want to create assemblies manually this is no problem, however the way you tried is not the correct way for Typhoon. What you need to do is:
##Example
We declare a property of type NetworkComponents, like this: And then to activate you just call:
Typhoon will automatically wire in the
Typhoon for Objective-C is nothing like Dagger 2. The way that it works is:
This is a very Objective-C-esque approach, which at the time Typhoon was written is what people were after. More info on assembly modularization is available here: https://github.com/appsquickly/Typhoon/wiki/Modularizing-Assemblies Typhoon for Swift is somewhat more like Dagger in that it uses compile-time rather than runtime processing. Thank you for trying Typhoon and let me know if you need further assistance setting up. |
Thank you for details, Jasper, but I didn't got what I did wrong... I've created assembly and it's fabric died after finishing the enclosing method. Example: @Property (nonatomic) TestAssemply *assembly;
It it bug or it's by design? |
Can you send me a sample project? Sounds like a bug or user error of some sort. Likely the latter. Your code above looks fine - sample project will help me understand better. |
@jasperblues @alexgarbarev @etolstoy I'm attaching a simple project where I believe this issue is replicated. Thanks in advance. |
Hello!
I'm newbie to Typhoon and hitting a lot of stupid problems on ObjC...
I prefer to create assemblies manually because using layered architecture and need to create new assembly for each user layer. It's not possible to use automatic assemblies generation because I have to inject some user specific information into the assembly.
Everything works fine until the end of the method.
After that any attempt to instantiate new object causes "method not found" crash.
I did some research and found that manually activated assemblies become instances of TyphoonAssemblyAccessor and later loosing reference to fabric property. This property resets to nil because declared as weak. It makes the assembly unusable anywhere outside the method scope where is was created because it immediately looses it's fabric.
I've figured out that the only way to keep this reference alive is to patch the sources (make it strong) or to make the assembly default.
This definitely is something that I do not want to do.
Please help.
PS: Please do not suggest to switch to Swift or use plist assemblies creation.
The text was updated successfully, but these errors were encountered: