Typhoon - Runtime Configurable Components Using Storyboard -
when application starts fetch remote config file containing info (urls, etc) required configure other dependencies.
after fetch remote config have config object need supply other typhoondefinitions.
now using plist storyboard integration.
i going downwards path of injecting assembly viewcontroller loads config object, , when receive remote config , create config object, somehow set property on assembly. did hoping utilize property in definitions, did not work , got:
2014-10-22 21:18:06.203 four[39840:516543] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'no component matching id 'setconfig:'.' *** first throw phone call stack: ( 0 corefoundation 0x000000010a3e63f5 __exceptionpreprocess + 165 1 libobjc.a.dylib 0x000000010a07fbb7 objc_exception_throw + 45 2 corefoundation 0x000000010a3e632d +[nsexception raise:format:] + 205 3 4 0x00000001070a011d -[typhooncomponentfactory componentforkey:args:] + 148 4 corefoundation 0x000000010a2de22c __invoking___ + 140 5 corefoundation 0x000000010a2de082 -[nsinvocation invoke] + 290 6 corefoundation 0x000000010a36d456 -[nsinvocation invokewithtarget:] + 54 7 4 0x000000010709d358 -[typhoonblockcomponentfactory forwardinvocation:] + 276 is there way me inject object assembly @ runtime?
is there cleaner way i'm trying do?
i reading run-time arguments sounds need, don't understand docs.
for example, have definition. need pass runtime config object parameter constructor.
- (id<apiservice>)apiservice { homecoming [typhoondefinition withclass:[apiservice class] configuration:^(typhoondefinition* definition) {}]; }
using runtime arguments
for example, have definition. need pass runtime config object parameter constructor.
- (id<apiservice>)apiservice { homecoming [typhoondefinition withclass:[apiservice class] configuration:^(typhoondefinition* definition) {}]; } try this:
- (id<apiservice>)apiservicewithconfig:(config *)config { homecoming [typhoondefinition withclass:[apiservice class] configuration:^(typhoondefinition* definition) { // inject property: [definition injectproperty:@selector(config) with:config]; // inject constructor: [definition useinitializer:@selector(initwithconfig:) parameters:^(typhoonmethod *initializer) { [initializer injectparameterwith:config]; }]; }]; } using mill definition
take next 2 definitions:
- (config *)currentconfig { homecoming [typhoondefinition withfactory:[self configmanager] selector:@selector(currentconfig)]; } - (configmanager *)configmanager { homecoming [typhoondefinition withclass:[configmanager class] configuration:^(typhoondefinition *definition){ definition.scope = typhoonscopesingleton; }]; } imagine have configmanager downloads remote config , stores 'currentconfig' property, 'configmanager' definition describes object.
then check 'currentconfig' definition. definition returns result of calling 'currentconfig'method on configmanager instance.
then can inject config as:
- (id<apiservice>)apiservice { homecoming [typhoondefinition withclass:[apiservice class] configuration:^(typhoondefinition* definition) { [definition injectproperty:@selector(config) with:[self currentconfig]]; }]; } but create sure currentconfig loaded (not nil) during 'apiservice' creation. (maybe improve inject configmanager instead - if currentconfig nil, filled later)
typhoon
No comments:
Post a Comment