ngrx

How to use withLatestFrom with a selector in ngrx?

吃可爱长大的小学妹 提交于 2020-05-30 11:37:42
问题 I have ngrx application, and I can't get the value from a selector in the effect, by the payload I sent in the component. I write an example code of what I deal with: This is my state, a simple docs array in it. export const initialState = { docs: [{ id: 1, name: "doc1" }, { id: 2, name: "doc2" }] }; export const reducer = createReducer( initialState, ); I dont handle any action for this questions, this is not the issue. In my component I get the array using a selector: docs$ = this.store

How to register ngrx sub features (StoreModule.forFeature()) for my angular app?

a 夏天 提交于 2020-05-30 07:24:05
问题 Following is my angular app structure app.module.ts -- StoreModule.forRoot() mainboard.module.ts --StoreModule.forFeature('mainboard', reducer) subFeature1.module.ts subFeature2.module.ts subFeature3.module.ts dashboard1.module.ts --StoreModule.forFeature('dashboard1', reducer) subFeature1.module.ts subFeature2.module.ts subFeature3.module.ts subFeature4.module.ts subFeature5.module.ts dashboard2.module.ts --StoreModule.forFeature('dashboard2', reducer) subFeature1.module.ts subFeature2

How to keep RxJs DRY

不想你离开。 提交于 2020-05-29 11:04:32
问题 DRY (Don't Repeat Yourself) Suppose I have this code used a lot in my app: observable$.pipe( tap(value => console.log(value)), map(value => value * 5), ... more repeated stuff ) Suppose that the value 5 is different in some parts of the code but everything else is identical. Can I somehow functionalise / do something to this to make it reusable to avoid copy paste issues? Could I do something like this? observable$.pipe( getReusedOperators(7), // this would pipe to all above operators using 7

How to keep RxJs DRY

白昼怎懂夜的黑 提交于 2020-05-29 11:03:52
问题 DRY (Don't Repeat Yourself) Suppose I have this code used a lot in my app: observable$.pipe( tap(value => console.log(value)), map(value => value * 5), ... more repeated stuff ) Suppose that the value 5 is different in some parts of the code but everything else is identical. Can I somehow functionalise / do something to this to make it reusable to avoid copy paste issues? Could I do something like this? observable$.pipe( getReusedOperators(7), // this would pipe to all above operators using 7

Wait until two Observables are complete

我的未来我决定 提交于 2020-05-13 18:14:06
问题 I want to call a method after two Observables have returned values. I did some searching and it seems like forkJoin is what I want, but I can't get it to work. I know both of these Observables are returning values, as I am using the data for each individually elsewhere in the component, so clearly I'm doing something else wrong. Here is what I tried. I'm using rxjs v6.4. forkJoin( this.store.pipe(select(fromStore.getAppointmentsLoading)), this.clientStore.pipe(select(fromClientStore

Overwriting handleSuccess of NGRX DefaultPersistenceResultHandler

独自空忆成欢 提交于 2020-04-16 02:35:35
问题 I am having a bit of difficulty with @ngrx/data and am hoping one of you Geniuses out there can help me out. I have an entity collection and would like to store some additional information to reduce round trips to the server and also reduce redundant loading. I have a table of data and only want to load one page at at time into the entity collection, in order to be able to do this I would like to add additional meta data to my collection so that I know when to load more data. E.g. when I

@ngrx/store-devtools for production mode

泄露秘密 提交于 2020-04-08 10:10:06
问题 I am using @ngrx/store-devtools instrumentation with the Chrome Extension. Does it has any sense to disable it for production mode? 回答1: You can simply not import it into your NgModule when you are in production mode by doing something like this: import { StoreDevtoolsModule } from '@ngrx/store-devtools'; let dev = [ StoreDevtoolsModule.instrumentOnlyWithExtension() ]; if (environment.production) { dev = []; enableProdMode(); } @NgModule({ imports: [ StoreModule.provideStore(rootReducer), ..

@ngrx/store-devtools for production mode

我是研究僧i 提交于 2020-04-08 10:09:44
问题 I am using @ngrx/store-devtools instrumentation with the Chrome Extension. Does it has any sense to disable it for production mode? 回答1: You can simply not import it into your NgModule when you are in production mode by doing something like this: import { StoreDevtoolsModule } from '@ngrx/store-devtools'; let dev = [ StoreDevtoolsModule.instrumentOnlyWithExtension() ]; if (environment.production) { dev = []; enableProdMode(); } @NgModule({ imports: [ StoreModule.provideStore(rootReducer), ..

@ngrx/store-devtools for production mode

一世执手 提交于 2020-04-08 10:08:51
问题 I am using @ngrx/store-devtools instrumentation with the Chrome Extension. Does it has any sense to disable it for production mode? 回答1: You can simply not import it into your NgModule when you are in production mode by doing something like this: import { StoreDevtoolsModule } from '@ngrx/store-devtools'; let dev = [ StoreDevtoolsModule.instrumentOnlyWithExtension() ]; if (environment.production) { dev = []; enableProdMode(); } @NgModule({ imports: [ StoreModule.provideStore(rootReducer), ..

create a selector for a ngrx/data entity

被刻印的时光 ゝ 提交于 2020-04-07 03:17:12
问题 I have a state and I'd like to create selectors from ngrx/data entities. import { Action, ActionReducer, ActionReducerMap, createFeatureSelector, createSelector, MetaReducer } from '@ngrx/store'; import {environment} from '../../environments/environment'; import * as fromRouter from '@ngrx/router-store'; import * as fromDrawer from './drawer'; import {InjectionToken} from '@angular/core'; import {NavigationItem} from '../models/navigation-item'; export interface State { router: fromRouter