Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngrx effects gives Type 'void' is not assignable to type 'ObservableInput'

@Injectable()
export class ApiSearchEffects {

  @Effect()
  search$: Observable<any>
    = this.actions$
    .ofType(query.ActionTypes.QUERYSERVER)
    .debounceTime(300)
    .map((action: query.QueryServerAction) => action.payload)
    .switchMap(payload => {
      console.log(payload);
      const nextSearch$ = this.actions$.ofType(query.ActionTypes.QUERYSERVER).skip(1);

      this.searchService.getsearchresults(payload)
        .takeUntil(nextSearch$)
        .map((response) =>
          ({type: '[Search] Change', payload: response}
          ))
    });

above code gives me Argument of type '(payload: any) => void' is not assignable to parameter of type '(value: any, index: number) => ObservableInput'. Type 'void' is not assignable to type 'ObservableInput'. where could be the mistake be. I have followed the ngrx effects official intro at https://github.com/ngrx/effects/blob/master/docs/intro.md .

like image 799
vanquishers Avatar asked Dec 08 '25 10:12

vanquishers


1 Answers

The problem is that your switchMap should return a value; its returning void as you have it.

Try this

  return this.searchService.getsearchresults(payload)
        .takeUntil(nextSearch$)
like image 193
Vamshi Avatar answered Dec 12 '25 23:12

Vamshi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!