Skip to content

Instantly share code, notes, and snippets.

@adamgen
Created May 6, 2020 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamgen/8936c8eb8628ae56c8ba41ffe60f298d to your computer and use it in GitHub Desktop.
Save adamgen/8936c8eb8628ae56c8ba41ffe60f298d to your computer and use it in GitHub Desktop.
NGRX | Use effects and router-store to isolate route related side ๐Ÿง™๐Ÿผโ€โ™‚๏ธ effects - good component
import { Store, select } from โ€˜@ngrx/storeโ€™;
import { Component } from โ€˜@angular/coreโ€™;
@Component({
selector: โ€˜app-rootโ€™,
template: `{{selectedId$ | async | json}}`,
})
export class HomeComponent {
selectedId$ = this.store.pipe(select((state: any) => state.featureName.selectedId));
constructor(
private store: Store,
) { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment