All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups Pages
TyphoonDefinition Class Reference
Inheritance diagram for TyphoonDefinition:

Properties

BOOL abstract
 If set, designates that a component can not be instantiated directly. More...
 
TyphoonAutoInjectVisibility autoInjectionVisibility
 Specifies visibility for for AutoInjection. More...
 
id parent
 A parent component. More...
 
TyphoonScope scope
 The scope of the component, default being TyphoonScopeObjectGraph. More...
 
Class type
 

Class Methods

(id) + withClass:
 
(id) + withClass:configuration:
 
(id) + withFactory:selector:
 A component that will produce an instance (with or without parameters) of this component. More...
 
(id) + withFactory:selector:parameters:
 
(id) + withFactory:selector:parameters:configuration:
 
(id) + withOption:matcher:
 Returns definition matching 'option', specified in 'matcherBlock'. More...
 
(id) + withOption:matcher:autoInjectionConfig:
 
(id) + withOption:yes:no:
 if boolean 'option' value is YES, then return yesInjection, otherwise return noInjection More...
 
(id) + withParent:class:
 Returns a definition that inherits initializer injections, property injections, method injections and scope from the specified parent definition. More...
 
(id) + withParent:class:configuration:
 Returns a definition that inherits initializer injections, property injections, method injections and scope from the specified parent definition, adding the specified configuration. More...
 

Instance Methods

(void) - injectMethod:parameters:
 Injects method specified by selector with parameters. More...
 
(void) - injectProperty:
 Injects property with a component from the container that matches the type (class or protocol) of the property. More...
 
(void) - injectProperty:with:
 Injects property for gives selector with injection, where injection can be. More...
 
(id) - keyPath:
 Returns injection which can be used for example in injectProperty:with: method This method will injects valueForKeyPath: with given keyPath. More...
 
(void) - performAfterInjections:
 A custom callback methods that is invoked after properties and method injection occurs. More...
 
(void) - performAfterInjections:parameters:
 
(void) - performBeforeInjections:
 A custom callback methods that is invoked before properties and method injection occurs. More...
 
(void) - performBeforeInjections:parameters:
 
(id) - property:
 Returns injection which can be used for example in injectProperty:with: method This method will injects result of selector invocation. More...
 
(void) - useInitializer:
 Convenience method to use a no-args initializer. More...
 
(void) - useInitializer:parameters:
 Injects initializer specified by selector and parameters. More...
 

Property Documentation

- (BOOL) abstract
readwritenonatomicassign

If set, designates that a component can not be instantiated directly.

See also
parent
- (TyphoonAutoInjectVisibility) autoInjectionVisibility
readwritenonatomicassign

Specifies visibility for for AutoInjection.

AutoInjection performs when using method:

  • (void)injectProperty:withSelector; or when using: InjectedClass or InjectedProtocol marco
- (id) parent
readwritenonatomicstrong

A parent component.

When parent is defined the initializer and/or properties from a definition are inherited, unless overridden. Example:

- (id)signUpClient
{
return [TyphoonDefinition withClass:[SignUpClientDefaultImpl class] configuration:^(TyphoonDefinition* definition)
{
definition.parent = [self abstractClient];
}];
}
- (id)abstractClient
{
return [TyphoonDefinition withClass:[ClientBase class] configuration:^(TyphoonDefinition* definition)
{
[definition injectProperty:@selector(serviceUrl) with:TyphoonConfig(@"service.url"];
[definition injectProperty:@selector(networkMonitor) with:[self internetMonitor]];
[definition injectProperty:@selector(allowInvalidSSLCertificates) with:@(YES)];
}];
}
See also
abstract
- (TyphoonScope) scope
readwritenonatomicassign

The scope of the component, default being TyphoonScopeObjectGraph.

- (Class) type
readnonatomicassign

Method Documentation

- (void) injectMethod: (SEL)  selector
parameters: (void(^)(TyphoonMethod *method))  parametersBlock 

Injects method specified by selector with parameters.

See also
TyphoonMethod documentation for information about parameters
- (void) injectProperty: (SEL)  withSelector

Injects property with a component from the container that matches the type (class or protocol) of the property.

- (void) injectProperty: (SEL)  selector
with: (id)  injection 

Injects property for gives selector with injection, where injection can be.

  • obtained from Injection* functions
  • another definition
  • assembly or collaboration assembly reference (TyphoonComponentFactory will be injected)
  • object instance
- (id) keyPath: (NSString *)  keyPath

Returns injection which can be used for example in injectProperty:with: method This method will injects valueForKeyPath: with given keyPath.

Parameters
keyPathpath used as argument while calling valueForKeyPath: on resolved definition
- (void) performAfterInjections: (SEL)  sel

A custom callback methods that is invoked after properties and method injection occurs.

- (void) performAfterInjections: (SEL)  sel
parameters: (void(^)(TyphoonMethod *param))  parameterBlock 
- (void) performBeforeInjections: (SEL)  sel

A custom callback methods that is invoked before properties and method injection occurs.

- (void) performBeforeInjections: (SEL)  sel
parameters: (void(^)(TyphoonMethod *params))  parametersBlock 
- (id) property: (SEL)  selector

Returns injection which can be used for example in injectProperty:with: method This method will injects result of selector invocation.

Parameters
selectorselector to invoke on resolved definition
- (void) useInitializer: (SEL)  selector

Convenience method to use a no-args initializer.

- (void) useInitializer: (SEL)  selector
parameters: (void(^)(TyphoonMethod *initializer))  parametersBlock 

Injects initializer specified by selector and parameters.

Initializer allow you to create object with special selector and params. Without this injection, object will be created by 'alloc-init' calls

+ (id) withClass: (Class)  clazz
+ (id) withClass: (Class)  clazz
configuration: (TyphoonDefinitionBlock injections 
+ (id) withFactory: (id)  factory
selector: (SEL)  selector 

A component that will produce an instance (with or without parameters) of this component.

For example:

- (id)sqliteManager
{
return [TyphoonDefinition withClass:[MySqliteManager class] configuration:^(TyphoonDefinition* definition)
{
[definition useInitializer:@selector(initWithDatabaseName:) parameters:^(TyphoonMethod* initializer)
{
[initializer injectParameterWith:@"database.sqlite"];
}];
definition.scope = TyphoonScopeSingleton;
}];
}
- (id)databaseQueue
{
return [TyphoonDefinition withClass:[FMDatabaseQueue class] configuration:^(TyphoonDefinition* definition)
{
[definition useInitializer:@selector(queue)];
definition.factory = [self sqliteManager];
}];
}
Note
If the factory method takes arguments, these are provided in the initializer block, just like a regular initializer method.
See also
injectProperty:withDefinition:selector: An alternative short-hand approach for no-args instances.
injectProperty:withDefinition:keyPath: An alternative short-hand approach for no-args instances.
TyphoonFactoryProvider - For creating factories where the configuration arguments are not known until runtime.
+ (id) withFactory: (id)  factory
selector: (SEL)  selector
parameters: (void(^)(TyphoonMethod *factoryMethod))  params 
+ (id) withFactory: (id)  factory
selector: (SEL)  selector
parameters: (void(^)(TyphoonMethod *factoryMethod))  params
configuration: (void(^)(TyphoonFactoryDefinition *definition))  configuration 
+ (id) withOption: (id)  option
matcher: (TyphoonMatcherBlock matcherBlock 

Returns definition matching 'option', specified in 'matcherBlock'.

Provided by category TyphoonDefinition(Option).

+ (id) withOption: (id)  option
matcher: (TyphoonMatcherBlock matcherBlock
autoInjectionConfig: (void(^)(id< TyphoonAutoInjectionConfig > config))  configBlock 

Provided by category TyphoonDefinition(Option).

+ (id) withOption: (id)  option
yes: (id)  yesInjection
no: (id)  noInjection 

if boolean 'option' value is YES, then return yesInjection, otherwise return noInjection

Provided by category TyphoonDefinition(Option).

+ (id) withParent: (id)  parent
class: (Class)  clazz 

Returns a definition that inherits initializer injections, property injections, method injections and scope from the specified parent definition.

Parent definitions can be chained.

+ (id) withParent: (id)  parent
class: (Class)  clazz
configuration: (TyphoonDefinitionBlock injections 

Returns a definition that inherits initializer injections, property injections, method injections and scope from the specified parent definition, adding the specified configuration.

Parent definitions can be chained.