Questions tagged ngrx

Explore the latest questions and answers asked by our top developers.

MergeMap in Ngrx Effect cause types error

i have NgRX effect class which i think is almost the same as in docs. import { Injectable } from ‘@angular/core’; import { Actions, createEffect, ofType } from ‘@ngrx/effects’; import { EMPTY } from ‘rxjs’; import { map, mergeMap, catchError } from ‘rxjs/operators’; import { SocialLearningFacadeService } from ‘../../facades/social-learning-facade.service’; import { loadCategories, retreivedCategories } from […]

By Zaben
Published
Categorized as angular, ngrx, store Tagged , ,

How to load data from meta reducer on refresh with lazy loading?

I have a meta-reducer that handles the whole state information and saves it on the localstorage. I implemented a lazy loading on one of my modules, I added up the StoreModule.forFeature() in the module file, everything is working, but if I refresh the page the data will be lost and will not be loaded from […]

By TyCy
Published
Categorized as angular, ngrx Tagged ,

Angular NGRX RXJS – Subscription to other observables inside effects don’t work

I have an issue, I have a service to manage SSE and I write this service: getAllNotify(url: string): Observable<EventDTO> { return new Observable(observer => { const eventSource = this.getEventSource(url); eventSource.onopen = function () { console.log(‘connection for all data is established’); }; eventSource.onmessage = event => { this.zone.run(() => { if (eventSource.readyState !== 0) { observer.next(JSON.parse(event.data)); […]

By Andy88
Published
Categorized as angular, ngrx, rxjs, typescript Tagged , , ,

Is it a bad practice to pass callbacks via ngrx actions

Consider the following case: A modal must be closed after an action succeeds. Would this be a viable solution: @Component({ selector: ‘user-delete-dialog’, templateUrl: ‘./user-delete-dialog.component.html’, styleUrls: [‘./user-delete-dialog.component.scss’] }) export class UserDeleteDialogComponent implements OnInit { @Input() user: User; constructor( public dialog: NgbActiveModal, private store: Store ) { } ngOnInit(): void { } confirm() { this.store.dispatch( deleteUser({ id: […]

By thomas
Published
Categorized as angular, ngrx Tagged ,

Angular lazy loaded module inits store multiple times

Hello I have a lazy loaded module (shoeSalesModule). ngrx/store/init appears to be called every time I load a component. As a result the store is reset. Is there a way to preserve the store’s state and only call init once? Here is my code. I am using Angular 12. Thanks! app-routing.module.ts import { NgModule } […]

By programmercurious82
Published
Categorized as angular, lazy-loading, ngrx Tagged , ,

Date subscription get triggered when other part of the state change in ngrx

I have a start and end property which stores a date in my state.Anytime other part of the state get changed my subscription for start and end date get triggered. this is my subscription this.subs.sink = this.store .select(fromTransactionReducer.selectStartAndEndDate) .subscribe((date) => { console.log("range", date); this.range.setValue({ start: date.start, end: date.end, }); }); this is the selector export […]

By walexy
Published
Categorized as angular, javascript, ngrx, ngrx-store, typescript Tagged , , , ,

Default params in ngrx getWithQuery()

I wonder how can send the default data already in getWithQuery(), like this: @Injectable({providedIn: ‘root’}) export class CompaniesDataService extends DefaultDataService<Company> { private readonly _URL: string = ‘/api/companies’; private readonly _DEFAULT_QUERIES: QueryParams = {top: ‘0’, limit: ’10’, order: "name"}; constructor(http: HttpClient, httpUrlGenerator: HttpUrlGenerator) { super(‘Company’, http, httpUrlGenerator); } getWithQuery(queryParams: QueryParams | string = this._DEFAULT_QUERIES): Observable<Company[]> { […]

By Ania
Published
Categorized as angular, angular-ngrx-data, ngrx Tagged , ,

Ngrx state mutability

I am currently trying to learn how to use Ngrx store and i’m having some trouble understanding something : In my app I have a state which is an Array of ingredient Objects in the form : {name : string , amount : number}. Now when I try to add a new object I want […]

By Alexander Uzelevski
Published
Categorized as angular, ngrx, state, store Tagged , , ,

About example to get single record from @ngrx/entity in Angular

I find there have many example to show how to get Multi Records into Array from @ngrx/entity But I difficult to find the example to show how to get record For example, in the action.ts export const coursesLoaded = createAction( ‘[Courses Effect] Courses Loaded Successfully’, props<{courses: Course[]}>() ); Then, I define the single course as […]

Infinity loop on NGRX dispatch

I write a simple to ngrx project to test store, but I got the infinity loop However I try to copy other example without loop. Firstly, I define 2 class model as below: export interface IBookRecords { id? : number; bookNumber?: string; guestID ? : number; guestName ? :string; bookdetails? : IBookDetail[]; } export interface […]

By Emily
Published
Categorized as angular, ngrx, redux, typescript Tagged , , ,
1 70

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq