Skip to content

Commit a354479

Browse files
committed
docs: Add conditional Entity invalidation mention in expiry policy concept page
1 parent 69ae187 commit a354479

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

docs/core/concepts/expiry-policy.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,3 +660,30 @@ render(<ShowTime />);
660660
[Controller.fetch()](../api/Controller.md#fetch) lets us update the server and store.
661661
We can use [Controller.setResponse()](../api/Controller.md#setResponse) for cases where we
662662
simply want to change the local store without updating the server.
663+
664+
#### Conditional Invalidation based on data
665+
666+
If `invalidation` should happen only sometimes, based on the response data, we can
667+
return `undefined` from [Entity.process](/rest/api/Entity#process).
668+
669+
```ts
670+
class PriceLevel extends Entity {
671+
price = 0;
672+
amount = 0;
673+
674+
pk() {
675+
return this.price;
676+
}
677+
678+
static process(
679+
input: [number, number],
680+
parent: any,
681+
key: string | undefined,
682+
): any {
683+
const [price, amount] = input;
684+
// highlight-next-line
685+
if (amount === 0) return undefined;
686+
return { price, amount };
687+
}
688+
}
689+
```

docs/rest/api/Entity.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,8 @@ class Stream extends Entity {
413413

414414
#### Dynamic Invalidation
415415

416-
Returning `undefined` from [Entity.process](https://dataclient.io/rest/api/Entity#process)
417-
will cause the [Entity](https://dataclient.io/rest/api/Entity) to be [invalidated](https://dataclient.io/docs/concepts/expiry-policy#invalidate-entity).
416+
Returning `undefined` from [Entity.process](#process)
417+
will cause the `Entity` to be [invalidated](/docs/concepts/expiry-policy#invalidate-entity).
418418
This this allows us to invalidate dynamically; based on the particular response data.
419419

420420
```ts

0 commit comments

Comments
 (0)