Post Impatica
Post Impatica

Reputation: 16383

Why is my ngrx Effect transforming a string parameter into an array?

Action

I have the following action:

export const searchTM = createAction(
    IocActionTypes.SearchTM,
    props<{tm: string}>()
);

Component

I have the following code in one of my components:

this.store.dispatch(searchTM(value));  

where value is the string 03F

Effects

In my ngrx Effects file I have the following:

searchTM$ = createEffect(() => this.actions$.pipe(
    ofType(iocActions.searchTM),
    mergeMap(val => this.iocService.getGridRowByTM(val.tm)
      .pipe(
        map(rowdataraw => iocActions.searchTMFound({rowdataraw})),
        catchError(() => {
            return EMPTY;
        })
      )
      )
    )
  );

but when I set a debug point on the mergeMap val variable, I see it come up like this:

enter image description here

Upvotes: 1

Views: 653

Answers (1)

Post Impatica
Post Impatica

Reputation: 16383

The problem was that I was passing the parameter in the wrong format.

I was using:

this.store.dispatch(searchTM(value));  

where I should have been using:

this.store.dispatch(searchTM({tm: value}));

Upvotes: 4

Related Questions