Created
December 3, 2017 23:35
-
-
Save ghetolay/0b4c549f6b7c7f3ac96b1a63c485fa9f to your computer and use it in GitHub Desktop.
Using DI for inputs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'some-parent', | |
providers: [ | |
{ provide: INPUT1, deps: [SomeSmartParent], useFactory: (cmp) => cmp.input1$ } | |
] | |
}) | |
export class SomeSmartParent { | |
input1$ = this.store.select(...).map(...); | |
} | |
@Component({ | |
selector: 'some-child', | |
changeDetection: ChangeDetectionStrategy.OnPush | |
}) | |
export class SomeChildNoMatterHowDeep { | |
constructor(private @Inject(INPUT1) input1$: Observable<any>); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment