Skip to content

No refetchObservableQueries - #293

Open
PowerKiKi wants to merge 1 commit into
masterfrom
issue-12584-no-automatic-refetch
Open

No refetchObservableQueries#293
PowerKiKi wants to merge 1 commit into
masterfrom
issue-12584-no-automatic-refetch

Conversation

@PowerKiKi

Copy link
Copy Markdown
Member

The most common use case for modelService.delete() is from a page detail, and after deletion the user is redirected to the page listing. So there is no need to refetchObservableQueries() unconditionally.

Other use cases

For other use cases we can reload specific queries like those examples.

Dialog

From a dialog on top of the listing page:

this.itemService
    .delete([id], {
        // Wait till we refresh the list under the dialog before closing the dialog, to avoid re-clicking on the just deleted item
        refetchQueries: [itemsQuery],
        awaitRefetchQueries: true,
    })
    .subscribe({
        next: () => {
            this.alertService.info(`Supprimé`);
            this.dialogRef.close();
        }
    });

Inline deletion in listing

From a listing page where deletion is directly accessible on the row:

this.itemService.delete([id], {
    refetchQueries: [itemsQuery],
}).subscribe({
    next: () => {
        this.alertService.info(`Supprimé`);
    },
    error: () => this.deleting.delete(id),
});

Bulk deleting

Bulk deleting via NaturalAbstractList.bulkDelete() still automatically refetch the listing of items, but no other queries anymore.

…)` #12584

The most common use case for `modelService.delete()` is from a page
detail, and after deletion the user is redirected to the page listing.
So there is no need to `refetchObservableQueries()` unconditionally.

# Other use cases

For other use cases we can reload specific queries like those
examples.

## Dialog

From a dialog on top of the listing page:

```ts
this.itemService
    .delete([id], {
        // Wait till we refresh the list under the dialog before closing the dialog, to avoid re-clicking on the just deleted item
        refetchQueries: [itemsQuery],
        awaitRefetchQueries: true,
    })
    .subscribe({
        next: () => {
            this.alertService.info(`Supprimé`);
            this.dialogRef.close();
        }
    });
```

## Inline deletion in listing

From a listing page where deletion is directly accessible on the row:

```ts
this.itemService.delete([id], {
    refetchQueries: [itemsQuery],
}).subscribe({
    next: () => {
        this.alertService.info(`Supprimé`);
    },
    error: () => this.deleting.delete(id),
});
```

## Bulk deleting

Bulk deleting via `NaturalAbstractList.bulkDelete()` still automatically
refetch the listing of items, but no other queries anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant