Skip to content

Instantly share code, notes, and snippets.

@ghetolay
Created December 3, 2017 23:35
Show Gist options
  • Save ghetolay/0b4c549f6b7c7f3ac96b1a63c485fa9f to your computer and use it in GitHub Desktop.
Save ghetolay/0b4c549f6b7c7f3ac96b1a63c485fa9f to your computer and use it in GitHub Desktop.
Using DI for inputs
@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