尽管 DELETE 出错,实体仍从缓存中移除

Entity removed from cache despite error on DELETE

我正在使用 Angular 8 和 @ngrx/data 来管理我的实体。当我启动失败的删除操作时(服务器 returns 500),该实体已从 ngrx 客户端缓存中删除,尽管它没有在服务器上被删除。

如何防止实体因错误而从缓存中删除?或者如何在错误时将(未)删除的实体重新添加回缓存?

使用悲观保存https://ngrx.io/guide/data/entity-change-tracker#save-errors

The EntityActions whose operation names end in _OPTIMISTIC start an optimistic save.

Many apps are easier to build when saves are "optimistic" because the changes are immediately available to application code that is watching collection selectors. The app doesn't have to wait for confirmation that the entity operation succeeded on the server.

A pessimistic save doesn't update the store until the server until the server confirms that the save succeeded, which NgRx Data then turns into a "SUCCESS" action that updates the collection. With a pessimistic save, the changes won't be available in the store