File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -370,7 +370,9 @@ Updates any [Queryable](/rest/api/schema#queryable) [Schema](/rest/api/schema#sc
370
370
```ts
371
371
ctrl.set(
372
372
Todo,
373
+ // which Todo to update
373
374
{ id : ' 5' } ,
375
+ // merge this data into the Todo in the store
374
376
{ id : ' 5' , title : ' tell me friends how great Data Client is' } ,
375
377
);
376
378
```
Original file line number Diff line number Diff line change @@ -615,10 +615,11 @@ import { useLoading } from '@data-client/react';
615
615
import { TimedEntity } from ' ./api/lastUpdated' ;
616
616
import TimePage from ' ./TimePage' ;
617
617
618
+ const InvalidateTimedEntity = new schema .Invalidate (TimedEntity );
618
619
export const deleteLastUpdated = new RestEndpoint ({
619
620
path: ' /api/currentTime/:id' ,
620
621
method: ' DELETE' ,
621
- schema: new schema . Invalidate ( TimedEntity ) ,
622
+ schema: InvalidateTimedEntity ,
622
623
});
623
624
624
625
function ShowTime() {
@@ -649,6 +650,17 @@ function ShowTime() {
649
650
>
650
651
Invalidate (without fetching DELETE)
651
652
</button >
653
+ <button
654
+ onClick = { () =>
655
+ ctrl .set (
656
+ InvalidateTimedEntity ,
657
+ { id: ' 1' },
658
+ { id: ' 1' },
659
+ )
660
+ }
661
+ >
662
+ Invalidate Entity with ctrl.set
663
+ </button >
652
664
</div >
653
665
);
654
666
}
@@ -658,8 +670,8 @@ render(<ShowTime />);
658
670
</HooksPlayground >
659
671
660
672
[ Controller.fetch()] ( ../api/Controller.md#fetch ) lets us update the server and store.
661
- We can use [ Controller.setResponse()] ( ../api/Controller.md#setResponse ) for cases where we
662
- simply want to change the local store without updating the server .
673
+ We can use [ Controller.setResponse()] ( ../api/Controller.md#setResponse ) or [ Controller.set() ] ( ../api/Controller.md#set )
674
+ when we want to change the local store directly .
663
675
664
676
#### Conditional Invalidation based on data
665
677
You can’t perform that action at this time.
0 commit comments