ngrx

ngrx normalized state selector

你。 提交于 2020-01-06 04:56:06
问题 I'm rewriting a Ionic project to work with ngrx because it is growing a lot and I need to maintain a centralized state. I have implemented it with ngrx and using normalized states with the help of Normalizr. Now I have a doubt on how to pass to dumb component a populated object: Suppose I have two interfaces: interface Conversation { date: Date, lastMessage: string //this is the id of a message entity coming from normalizr } and interface Message { content: string } Now when I'm trying to get

Angular NgRx - Effect to continue polling a service only called the first time

流过昼夜 提交于 2020-01-04 14:16:23
问题 I have an application where I have just added NgRX where I wish to use effects to switch polling on and off. Sample outline I followed this post which seemed like a good approach. I have a simplified example of this here, with the bulk of the code is in app.effects.ts . Similar to the example, I have the effects startPolling$ , stopPolling$ and continuePolling$ , except I am using the newer createEffect factory methods. Also, I have moved the delay(2000) above the takeWhile() , as I found if

Other operator in calculation chain than combineLatest to avoid redundant calculations

自古美人都是妖i 提交于 2020-01-04 05:21:22
问题 I've successfully migrated a larger Excel calculation to JS using RxJS. Any input data is represented as an Observable and subsequent calculations are implemented with .map and .combineLatest when any Excel formula uses more than one input. This works great except for one problem. Here is a simplified example: Three inputs ( a$=1 , b$=2 , c$=3 ) are used in two different calculations ( $ab = $a+$b = 3 in the first, $bc = $b+$c = 5 in the second) as intermediate steps to calculate the final

Should I reset my redux store on each router navigation?

社会主义新天地 提交于 2020-01-04 04:17:18
问题 I'm using Angular to write my application, and I use Redux through ngrx/store to store my application state. Everything work fine, but now that my application get pretty large, I came with the following observation: For nearly each page/resource, I use a different resolver that fetch from my backend, all the data necessary to correctly display and act on this particular page. This resolver allow me to make this page independent from the previous state of the application. So if the application

ngrx polling to refresh data when subscribed

一曲冷凌霜 提交于 2020-01-03 16:49:29
问题 Context I am using the following libraries in the relevant application: Angular 4.x, ngrx 4.x, rxjs 5.4.x In my application I am able to get some data from a websocket but for some I have to hit a RESTful api. I am sharing the data between multiple components through ngrx. Right now I refetch the data based on events like create, update, and delete. I don't expect much concurrent modification of the data but I do need a way to manually or automatically ensure that my client state matches the

ngrx polling to refresh data when subscribed

做~自己de王妃 提交于 2020-01-03 16:49:12
问题 Context I am using the following libraries in the relevant application: Angular 4.x, ngrx 4.x, rxjs 5.4.x In my application I am able to get some data from a websocket but for some I have to hit a RESTful api. I am sharing the data between multiple components through ngrx. Right now I refetch the data based on events like create, update, and delete. I don't expect much concurrent modification of the data but I do need a way to manually or automatically ensure that my client state matches the

Navigation ID is not equal to the current router navigation id error

蹲街弑〆低调 提交于 2020-01-03 06:48:11
问题 I'm using @ngrx/router-store in my Angularv5 app and I recently started running into a an error: Navigation ID X is not equal to the current navigation id Y (where X and Y are integers). This problem happens consistently when I navigate to route A from a specific route B. Navigating to route A from any other route seems to work fine. The only other S.O. issue related to this which I've found, offers up the possibility that the issue could be caused by rapidly updating the navigation multiple

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

Angular2 + ngrx/store for handling failure HTTP requests

℡╲_俬逩灬. 提交于 2020-01-02 02:23:07
问题 I want to have a simple code path for creating and dispatching HTTP actions. What I would like to do is something like: this.http.request(...) .map((res: Response) => res.json()) .catch((err: any) => err.json()) .map((payload: any) => { type: 'SUCCESS', payload }) .catch((payload: any) => { type: 'FAILURE', payload}) .subscribe((action: Action) => this.store.dispatch(action)); That way both the success and failure responses are converted to JSON and then based upon the success/fail criteria

@ngrx 4 how to filter current loaded data

微笑、不失礼 提交于 2020-01-01 12:31:11
问题 I am working on a new angular 4 plus @ngrx 4 project. I wish to have a searching function on the loaded data. For example, all the contacts info have been loaded in the component. The contacts list will be filtered which contact name matched with the search text. Please see screenshot As the data is existed in store and I do not wish to call web api service again. Any idea or demo code would be appreciated. 回答1: You can follow this flow to search what you need on already fetched content: Use