ngrx-store

ngrx store does not update UI after dispatched action from firebase promise

落爺英雄遲暮 提交于 2020-01-24 20:16:18
问题 I am trying to develop a basic NativeScript app using Angular 4. I am also using ngrx store and firebase as a realtime database. When I use a sample array and update the store and not integrate with firebase the program works fine. UI gets updated too. let value = [ { "description": "Groups discussing about Technology", "category": "Tech" }, { "description": "Groups for all kinds of sports ", "category": "Sports" } ]; this.store.dispatch({ type: GroupCategoryListActions.ADD_ITEMS, payload:

Reducers and immutability in ngrx

a 夏天 提交于 2020-01-22 20:36:29
问题 When creating a reducer function in ngrx, everywhere I read says that I should return a copy of the original/previous state. Either by using spread operators or by using a library or tricks like JSON.parse(JSON.stringify(state)) . But I found one catch there and I couldn't find anyone talking about it. The last state returned in a reducer is the state that's going to be shared with all current subscribers and with future subscribers too. That means that all components that use a certain store

Independent instances of the same NgRx feature module

ⅰ亾dé卋堺 提交于 2020-01-22 13:49:50
问题 I am working on an Angular 5 project using NgRx 5. So far I've implemented a skeleton app and a feature module called "Search" which handles its own state, actions and reducers in an encapsulated fashion (by using the forFeature syntax). This module has one root component ( search-container ) which renders an entire tree of child components - together they make up the search UI and functionality, which has a complex state model and a good number of actions and reducers. There are strong

How to create local effect in ngrx/effects

匆匆过客 提交于 2020-01-17 06:58:57
问题 How can I do something like that in ngrx/effects: // I want to handle a sign up effect return this.actions$.ofType(user.SIGN_UP_SUCCESS) .map((action: user.SignUpSuccessAction) => action.payload) .mergeMap(() => { // then I have to call two other async actions to add new records return [ new userOptions.Add(new UserOptionsModel()); new userInfo.Add(new UserInfoModel()); ]; }) How can I handle success actions for both userOptions and userInfo actions and then redirect to a Dashboard page? I

How to set initialState in @ngrx/core with a promise from indexedDB

那年仲夏 提交于 2020-01-02 18:04:31
问题 I wanted to set the initial state in ngrx using the idb package which uses promise to fetch data, but am getting an error every time I tried to set it up. I read that @ngrx is synchronous does that mean it does not work with promises. The different methods I tried: this is my wrapper method for idb that loads in the data it works fine export function getInitialState(): Promise<any> { return StorageService.dB.loadInitialState('app-state'); } and the different methods I tried set the initial

Warning from ngrx about runtime checks

[亡魂溺海] 提交于 2019-12-30 17:19:32
问题 I upgraded my app from Angular 7 to Angular 8 using ng update . When I run it via ng serve , There's a warning printed in my console from ngrx : @ngrx/store: runtime checks are currently opt-in but will be the default in the next major version with the possibility to opt-out, see https://ngrx.io/guide/migration/v8 for more information. The documentation at the provided link talks about ngrx-store-freeze being deprecated. However, my application does not use ngrx-store-freeze , and I have no

How to add state properties from component

ぐ巨炮叔叔 提交于 2019-12-25 01:46:39
问题 I'm currently working on a project that involves state management for individual components using Angular 7 and NGRX. However, I need to make this implementation scalable, meaning it can be used multiple times while still working independent. So far I have managed to get my state running and sorted out all action in my reducer, alongside all effects. Currently I have this in my reducer: export interface State extends fromRoot.State { widgets: WidgetState; } //interface for the specific chunk

AsyncPipe initial value null only if subscription is not shared

若如初见. 提交于 2019-12-24 18:34:58
问题 Given a template that looks like something like this <some-component *ngIf="someColdObservable$ | async" [result]="someColdObservable$ | async" ></some-component> and an observable that looks like this: someColdObservable$: this.store.pipe( select(isAllowedToDoThis), filter(Boolean), flatMap(() => apiRequest()) ); The someColdObservable$ gets subscribed to twice (as expected), which in turn issues two api calls (this is obviously a code smell, but let's disregard that at the moment). In this

How to update states of multiple reducers with a single action in ngrx store?

泄露秘密 提交于 2019-12-24 11:57:17
问题 I have multiple reducers in my application which are combined in app.reducers.ts. When my action happens state of one reducer should be update with single value from current state of the other reducer(so unplanned delivery will become scheduled) and then remove that value from state of second reducer. Here is how I can delete it, but before doing this I need to update other state. case UNPLANNED_ACTIONS.REMOVE_UNPLANNED_DELIVERY: return Object.assign({}, state, { deliveries: state.deliveries

NGRX Effect Typescript Error When Trying to Return Multiple Actions

落花浮王杯 提交于 2019-12-24 10:44:47
问题 I'm facing some difficulties when trying to return multiple actions in my NGRX effect. I know how to return multiple actions, but I'm trying to set up two sets of actions to fire based on a boolean value. The code is as follows: @Effect() loadCompanyDetail = this.actions$ .ofType(fromActions.COMPANY_DETAIL_LOAD) .pipe( switchMap(() => { return this.companyService .getCompanyByID( fromUtility.obs2Str( this.routerStore.select(fromRouter.getCompanyId) ) ) .pipe( switchMap(res => { switch (res