Last active
August 23, 2021 12:29
-
-
Save fyodorio/21b7686161b4d34c12af57767e4ad53f to your computer and use it in GitHub Desktop.
Example of NgRx facade
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
@Injectable() | |
export class ConfigurationsFacade { | |
/** | |
* Combine pieces of state using createSelector, | |
* and expose them as observables through the facade. | |
*/ | |
loaded$ = this.store.pipe(select(ConfigurationsSelectors.getConfigurationsLoaded)); | |
failed$ = this.store.pipe(select(ConfigurationsSelectors.getConfigurationsLoadFailed)); | |
allConfigurations$: Observable<Configuration[]> = this.store.pipe(select(ConfigurationsSelectors.getAllConfigurations)); | |
selectedConfigurations$ = this.store.pipe(select(ConfigurationsSelectors.getSelected)); | |
constructor(private store: Store) {} | |
/** | |
* Use the initialization action to perform one | |
* or more tasks in your Effects. | |
*/ | |
loadConfigurations() { | |
this.store.dispatch(ConfigurationsActions.loadConfigurations()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment