ngrx-store-4.0

ngrx parameter to select function

╄→尐↘猪︶ㄣ 提交于 2019-12-25 11:55:03
问题 Is there a way to pass parameters to ngrx select functions? Following is my use case: I am maintaining list of comments in store. I wrote one component to represent one comment. So, one CommentComponent knows the id of the component object Each comment will have properties like likedBy, reportedBy, ...etc In UI, I am showing all the components using *ngFor Now I want my CommentComponent to subscribe only to one comment object by using id of the component. Right now I am subscribing to all the

@ngrx/store combine multiple reducers from feature module

血红的双手。 提交于 2019-12-20 19:47:35
问题 I am currently working on a simple test app to learn more about the @ngrx/store. I have a module called TrainingModule which should store some exercises and more information. The code works, but i try to improve here. What i currently have is my feature module that looks like this: @NgModule({ imports: [ CommonModule, TrainingRoutingModule, StoreModule.forFeature('exercises', exerciseReducer) ], declarations: [ TrainingDashboardComponent, TrainingCoreComponent, TrainingNavComponent,

Providing root reducer in @ngrx/store 4.0

丶灬走出姿态 提交于 2019-12-18 12:34:17
问题 In @ngrx/store 2.0 we could provide the root reducer as a function and from there we split our logic inside the application. After I updated to @ngrx/store 4.0 I cannot use this feature any more from what I can see the reducers need to be a map of reducers which will create objects under the same keys in the state. Is there a way to use the old behavoir in @ngrx/store 4.0 In my state components are aware one of another and I need to be able to split my state dynamically also I need to be able

Providing root reducer in @ngrx/store 4.0

帅比萌擦擦* 提交于 2019-12-18 12:34:14
问题 In @ngrx/store 2.0 we could provide the root reducer as a function and from there we split our logic inside the application. After I updated to @ngrx/store 4.0 I cannot use this feature any more from what I can see the reducers need to be a map of reducers which will create objects under the same keys in the state. Is there a way to use the old behavoir in @ngrx/store 4.0 In my state components are aware one of another and I need to be able to split my state dynamically also I need to be able

Angular router guard and ROUTER_NAVIGATION effect order

时光毁灭记忆、已成空白 提交于 2019-12-13 12:12:23
问题 There is a simple (Angular 4) route guard, which waits for some data to be loaded from backend: @Injectable() export class ContractsLoadedGuard implements CanActivate { constructor(private store: Store<State>) { } waitForData(): Observable<boolean> { return this.store.select(state => state.contracts) .map(contractList => !!contractList) .filter(loaded => loaded) .take(1); } canActivate(): Observable<boolean> { return this.waitForData(); } } Routing: const routes: Routes = [ { path: 'app-list'

Property 'replaceReducer' does not exist on type 'Store<State>' After upgrading @ngrx/store

大憨熊 提交于 2019-12-13 03:23:53
问题 In my Angular app, I have a function which replaces replaces the current reducer used by the Store. However, after upgrade from @ngrx/store v2.2.2 to v6.1.0, "replaceReducer" function seems to have been removed from the Store interface. I've gone through the NGRX migration guide (https://github.com/ngrx/platform/blob/master/MIGRATION.md) hoping to find a possible solution or an alternative way to go around the issue but I can't find any reference to the removed "replaceReducer" function

i18n with ngrx store - translating angular application

丶灬走出姿态 提交于 2019-12-12 23:38:41
问题 I'm writing to ask you for advice. We build store based angular application, which requires translation. The request is to use official angular i18n method, although I have no idea how to connect my translations with values from the store. Is it even possible, does anyone have any experience with this or should I straight away go to the solutions like ngx-translate library..? I must say I researched quite a bit, but have not found understandable (I'm a junior and it's pretty hard for me to

changing the store state from component ngrx

こ雲淡風輕ζ 提交于 2019-12-12 16:54:52
问题 I'm using selectors to select from the store this.quizz = this.store.select(getSelectedQuizz); I use the async pipe to read from this observable like this in the template [*ngIf="quizz | async; let quizz"] I only define the action and I didn't modify the reducer yet the template is a form when I save the form I dispatch an update action which is only defined in my actions with readonly but I notice that when ever I save the form and dispatch the action the store changed and I didn't specify

Ngrx testing - How to configure TestBed in order to instantiate the entire state store in a test

时光怂恿深爱的人放手 提交于 2019-12-11 13:47:28
问题 I want to run some integration tests for the ngrx 4 state store in an Angular 5 app. My desire is to test dispatching ngrx actions, effects, webapi, mock server and selectors all together in one shot. Writting separate tests for effects and reducers is going to be a time sink and I need to cut some corners. I only need to know when one of my pages fails not the exact spot. I managed to do this in a previous project while using redux together with Angular 2. That was quite easy to setup.

NullInjectorError: No provider for ReducerManager

浪尽此生 提交于 2019-12-08 15:57:41
问题 I am using the new ngrx 5. This is the file that holds the reducers and the featureSelector: import AppState from '../interfaces/app.state' import { ActionReducerMap, createFeatureSelector } from '@ngrx/store' import { partnerReducer } from './partner.reducer' export const reducers: ActionReducerMap<AppState> = { partnerState: partnerReducer } export const getAppState = createFeatureSelector<AppState>('appState') This is how I am importing the storeModule @NgModule({ declarations: [...],