-
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
Implement <TyphoonDetachableComponentFactoryPostProcessor> #171
Comments
This is sample code. - (void)setUp
{
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
TyphoonComponentFactory *factory = [TyphoonBlockComponentFactory factoryWithAssemblies:@[[ComponentsAssembly assembly]]];
TyphoonPatcher *patcher = [TyphoonPatcher new];
[patcher patchDefinitionWithKey:@"dataManager" withObject:^id{
return [DataManager new];
}];
[factory attachPostProcessor:patcher];
[factory makeDefault];
}
- (void)testExample
{
DataManager *manager = [[TyphoonComponentFactory defaultFactory] componentForKey:@"dataManager"];
[(TyphoonComponentFactory *)[TyphoonComponentFactory defaultFactory] unload];
manager = [[TyphoonComponentFactory defaultFactory] componentForKey:@"dataManager"];
XCTAssertTrue(YES);
} |
To implement [patcher detach] we need to implement on
. . . so that we can save the old pre-patched definitions. |
Changing from bug to enhancement. Calling unload on TyphoonComponentFactory as done in the example will unload the singletons, however once a post-processor has been attached the definitions are permanently mutated. . . . so what is really required is a <TyphoonDetachableComponentFactoryPostProcessor> |
Have implemented the copy methods, now need to create and make the patcher conform to |
@rizumita We've been very busy! Will close this issue ASAP. (perhaps not until after Friday). |
@rizumita This has now been implemented. A patcher can be removed by calling: [patcher detach]; To test use: pod 'Typhoon', :head (we'll push a new version after we receive your 👍 )
|
I don't use the 'detach' method in test code and the following error log was outputted.
Then I use the 'detach' method and I got no error. Thank you for the enhancement! |
:) pushed to CocoaPods as 2.0.3 |
NSInvalidArgumentException "Key 'synchronizeOperation$$$patcher' is already registered.” raised at creating object by factory after calling TyphoonComponentFactory’s unload method.
The text was updated successfully, but these errors were encountered: