ngrx

Which merge operator to use to listen to single source and not 2nd stream source

瘦欲@ 提交于 2019-12-23 23:17:44
问题 So I know the question may seem simple, but it's not that simple. All the operators I have tried such as combineLatest , concat , and switchMap result in diff issues. So here is the challenge: var campaignSelected$ = this.store.select(store => store.appDb.uiState.campaign.campaignSelected) var campaignsList$ = this.store.select(store => store.msDatabase.sdk.table_campaigns); return campaignSelected$.switchMap(i_campaignSelected => campaignsList$, (campaignId, campaigns) => { return 'foo'; })

Create non-memoized selector on ngrx

半城伤御伤魂 提交于 2019-12-23 14:20:10
问题 Is it possible to create a non-memoized selector on ngrx? I have a very small selector to check whether a value in the store is greater than Date.now(). export const selectAuthState = createFeatureSelector<AuthState>('auth'); export const hasTimeout = createSelector( selectAuthState, state => state.timeout < Date.now() ); As expected, this selector is not useful since it won't be recalculated unless I change the value of timeout . Is there any way to make the selector non-memoized, so that it

Create non-memoized selector on ngrx

梦想与她 提交于 2019-12-23 14:19:24
问题 Is it possible to create a non-memoized selector on ngrx? I have a very small selector to check whether a value in the store is greater than Date.now(). export const selectAuthState = createFeatureSelector<AuthState>('auth'); export const hasTimeout = createSelector( selectAuthState, state => state.timeout < Date.now() ); As expected, this selector is not useful since it won't be recalculated unless I change the value of timeout . Is there any way to make the selector non-memoized, so that it

Angular2 AoT - Expression form not supported

这一生的挚爱 提交于 2019-12-23 12:27:26
问题 I'm trying to use ngc to compile angular 2.4.4: Error: Error encountered resolving symbol values statically. Expression form not supported (position 52:9 in the original .ts file), resolving symbol DEFAULT_APP_STATE in... It looks like it is complaining about how i'm exporting a constant for @ngrx/store. I tried changing the constant into an exported function... as well as all of the properties. Previously: export const DEFAULT_APP_STATE = { Offline: DEFAULT_APP_OFFLINE_STATE, Initialized:

Function calls are not supported in decorators

最后都变了- 提交于 2019-12-23 10:49:31
问题 I am facing an issue while ng build --prod: Function calls are not supported in decorators but 'Ui' was called in 'initialState' export const initialState: AppState = { userAisles: null, userItems: null, userLists: null, userShops: null, ui: new Ui(), config: new Config(), }; and my Ui class: export class Ui { loading: false; itemsOrder = 'name'; itemsOrderSense = 'ASC'; listsOrder = 'date'; listsOrderSense = 'ASC'; listsConsultOrder = 'name'; listsConsultOrderSense = 'ASC'; history: string =

Angular - “TypeError: Cannot freeze” when dispatching an action

瘦欲@ 提交于 2019-12-23 09:36:35
问题 I'm working on an angular app that uses ngrx store & effects. I get "TypeError: Cannot freeze" error when dispatching an action from my component. I wrote it for a file upload feature. I think that I'm mutating the state but cannot figure out where and how to solve it. Here's my detailed code: Actions: export enum FileUploadActionTypes { UploadFile = '[File Upload] Upload File', UploadFileSuccess = '[File Upload] Upload File Success', UploadFileFailure = '[File Upload] Upload File Failure' }

How to set md-select panel to be open by default

蹲街弑〆低调 提交于 2019-12-23 05:17:27
问题 I am using angular4 with Redux and angular material to design my web page. I am trying to set the md-select panel to be open. example scenario: click button dispatches an action to open the select panel opens to dispaly all options. I am using redux actions to manipulate my components state. So basically I need to fire an action to set the select to open. Any suggestions? 回答1: Using the Material2 example as starting point for this answer. Here is how you can do that: Give an id to your panel,

NgRX Effect for downloading media file and dispatching progress; how to deal with the stream and throttling

只愿长相守 提交于 2019-12-22 18:05:02
问题 I am struggling a bit with understanding and applying @Effects for my episode Download option. I got some help in another question and this is my latest concoction. Quick overview: User clicks download which dispatches a DOWNLOAD_EPISODE action which is captured in the first Effect. The download call returns a stream of HttpEvents and a final HttpResponse. During the event.type === 3 I want to report download progress. When event.type === 4 the body has arrived and I can call the success

ngrx, How to have a starting state from an api?

谁说胖子不能爱 提交于 2019-12-22 13:59:42
问题 I have my reducer with a starting state of an empty array: folderReducer(state:Array<Folder> = [], action: Action) I'd like to populate the starting state, so when I do store.subscribe(s => ..) The first item I get comes from the database. I assume the way of doing this is with ngrx/effects, but I'm not sure how. 回答1: Your store always has the initial state , that you define in the reducer-function. The initial states main purpose is to ensure that the application is able to start up and not

Structuring state management store (ngrx/redux). Flat as representative of data, or nested as representative of view?

半城伤御伤魂 提交于 2019-12-22 05:05:19
问题 I'm using ngrx store, to maintain application state, normalizr to flatten my data from API calls and Immutable. So far it's been working really well, but I'm getting to some more complex data relationships and I was wondering how to proceed with structuring the store. To simplify things, I have two sets of objects. Sessions, and Invoices. One user logs on and can view his list of Sessions. The state in the store is held in an object ISessions : export interface ISessions extends Map<String,