Skip to content
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

Auto-inject assembly by protocol #529

Open
Emailrus opened this issue Sep 8, 2016 · 3 comments
Open

Auto-inject assembly by protocol #529

Emailrus opened this issue Sep 8, 2016 · 3 comments

Comments

@Emailrus
Copy link
Contributor

Emailrus commented Sep 8, 2016

Related post on SO

It might be nice to have an ability for assemblies to auto-inject themselves, for example:

@protocol IFormatterProvider <NSObject>

- (id)statusTextFormatter;

@end

@interface MyAssembly : TyphoonAssembly <IFormatterProvider>
@end

@implementation MyAssembly

- (id <IFormatterProvider>)formatterProvider 
{
    return [TyphoonDefinition with:self]; // or something similar
}

- (id)statusTextFormatter
{
    // impl
}

@end

// -------

@interface MyStuff ()

@property (nonatomic, strong) InjectedProtocol(IFormatterProvider)formatterProvider;

@end

This way we don't have to create a factory as a separate class (assembly will act as one), no need to write injectProperty stuff in assemblies (to manually inject assembly) and therefore will be no warnings about using undeclared selectors (in case of injected properties being declared in class extension).

@alexgarbarev
Copy link
Contributor

Thats' quite easy to add. There is few ways to achieve that. (Add new kind of definition, adjust TyphoonInjectionDefinition etc..)

@jasperblues
Copy link
Member

👍 I like it

@etolstoy etolstoy self-assigned this Feb 6, 2017
@jasperblues
Copy link
Member

Still interested in working on this @etolstoy ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants