-
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
Are Lazy properties needed? #203
Comments
Lots of folks have reported using them. But it would probably be fair enough to not support them in combination with lazy. |
I changed internal API for property and parameter injections, now both used via method: - (void)valueToInjectWithContext:(TyphoonInjectionContext *)context completion:(TyphoonInjectionValueBlock)result; I had problem with creation lazyValues, used in TyphoonAssistedFactoryBase, because new API assume that value returned asyncronically (after resovling circular dependencies). Finally I got: - (void)doPropertyInjectionIfNeededOn:(id <TyphoonIntrospectiveNSObject, TyphoonPropertyInjectionInternalDelegate>)instance property:(id <TyphoonPropertyInjection>)property
args:(TyphoonRuntimeArguments *)args
{
if ([instance respondsToSelector:@selector(shouldInjectProperty:withType:lazyValue:)]) {
TyphoonTypeDescriptor *propertyType = [instance typhoon_typeForPropertyWithName:property.propertyName];
TyphoonPropertyInjectionLazyValue lazyValue = ^id {
TyphoonInjectionContext *context = [[TyphoonInjectionContext alloc] init];
context.destinationType = propertyType;
context.factory = self;
context.args = args;
context.raiseExceptionIfCircular = YES;
__block id result = nil;
[property valueToInjectWithContext:context completion:^(id value) {
result = value;
}];
return result;
};
if ([instance shouldInjectProperty:property withType:propertyType lazyValue:lazyValue]) {
[self doPropertyInjection:instance property:property args:args];
}
} else {
[self doPropertyInjection:instance property:property args:args];
}
} So, if lazyValue has circular dependency, exceptions will be raised. Is it ok? |
I didn’t understand at first what “lazy” properties you meant. I will try to have a look at them later. But I don’t think I implemented them with circular dependencies in mind. |
I think you used it when user fills TyphoonAssistedFactoryBase with property injections - to not resolve properties which user not used in future |
'lazy simply meant 'Don't instantiate signletons until they're asked for' On Tue, Mar 25, 2014 at 4:00 AM, Aleksey Garbarev
|
I have problems with supporting it when reworking circular dependencies code.
The text was updated successfully, but these errors were encountered: