Skip to content

Commit

Permalink
Update readme examples of live reload
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriLojda committed Jun 19, 2024
1 parent 9009fe8 commit 32ac9b0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,10 @@ import KontentSmartLink, { KontentSmartLinkEvent, applyUpdateOnItem, applyUpdate
// Initialize the SDK
const sdk = KontentSmartLink.initialize({ ... });

const fetchItemsFromDeliveryApi = (itemCodenames: ReadonlyArray<string>) => client.items().inFilter(system.codename, items).toAllPromise().then(res => res.data.items);

// Listen for updates and apply them to your application
sdk.on(KontentSmartLink.Update, (data: IUpdateMessageData) => {
sdk.on(KontentSmartLinkEvent.Update, (data: IUpdateMessageData) => {
// Use this data to update your application state or UI as needed e.g.:
setItems((items) => items.map(item => applyUpdateOnItem(item, data)));
// or
Expand Down

0 comments on commit 32ac9b0

Please sign in to comment.