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
370370```ts
371371ctrl.set(
372372 Todo,
373+ // which Todo to update
373374 { id : ' 5' } ,
375+ // merge this data into the Todo in the store
374376 { id : ' 5' , title : ' tell me friends how great Data Client is' } ,
375377);
376378```
Original file line number Diff line number Diff line change @@ -615,10 +615,11 @@ import { useLoading } from '@data-client/react';
615615import { TimedEntity } from ' ./api/lastUpdated' ;
616616import TimePage from ' ./TimePage' ;
617617
618+ const InvalidateTimedEntity = new schema .Invalidate (TimedEntity );
618619export const deleteLastUpdated = new RestEndpoint ({
619620 path: ' /api/currentTime/:id' ,
620621 method: ' DELETE' ,
621- schema: new schema . Invalidate ( TimedEntity ) ,
622+ schema: InvalidateTimedEntity ,
622623});
623624
624625function ShowTime() {
@@ -649,6 +650,17 @@ function ShowTime() {
649650 >
650651 Invalidate (without fetching DELETE)
651652 </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 >
652664 </div >
653665 );
654666}
@@ -658,8 +670,8 @@ render(<ShowTime />);
658670</HooksPlayground >
659671
660672[ 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 .
663675
664676#### Conditional Invalidation based on data
665677
You can’t perform that action at this time.
0 commit comments