filter observable without triggering http request

Discussão em 'Angular' iniciado por derstauner, Abril 21, 2025.

  1. derstauner

    derstauner Guest

    I populate a grid with the following line of code:

    this.gridData$ = this.userService.getUsers();


    And this is the corresponding html:

    [kendoGridBinding]="(gridData$ | async)!"


    It works as expected.

    I have also a delete button. Clicking the button deletes the user. After that I want to remove the user from the list, but withount making an extra http request. I tried shareReplay, but the extra request is there:

    this.gridData$ = this.gridData$.pipe(
    shareReplay({ bufferSize: 1, refCount: true }),
    map((users) => {
    return users.filter(
    (user) => user.userId !== this.currentDataItem.userId
    );
    })
    );


    So, the question is, how to filter the grid data in order to delete the deleted user without any extra http request? Or should I store the users in a local variable on init, and modify the array upon adding, edit or delete and convert this to an observable?

    Continue reading...

Compartilhe esta Página