-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🆕 new custom json stores system for custom data sharing / persistance…
… across apps
- Loading branch information
Showing
12 changed files
with
183 additions
and
84 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
library/CushyStudio/examples/tutorial/widgets/example-custom-store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
app({ | ||
ui: (ui) => ({ | ||
help: ui.markdown({ | ||
label: false, | ||
markdown: [ | ||
// | ||
`This example showcase how apps can remember data across`, | ||
`multiple runs though custom data store.`, | ||
`- Press play to see the amount of times you've pressed play`, | ||
`- 📝 note: you can restart the app, update it, it will remember how many times you pressed it.`, | ||
].join('\n\n'), | ||
}), | ||
}), | ||
|
||
run: async (sdk, ui) => { | ||
const store = sdk.getStore_orCreateIfMissing('example-key-1337', () => ({ count: 0 })) | ||
const prevValue = store.get() | ||
sdk.output_Markdown( | ||
[ | ||
// | ||
`store created: **${sdk.formatAsRelativeDateTime(store.createdAt)}**`, | ||
`previous run : **${sdk.formatAsRelativeDateTime(store.updatedAt)}**`, | ||
`run count : **${store.get().count + 1} times**`, | ||
].join('\n\n'), | ||
) | ||
store.update({ json: { count: prevValue.count + 1 } }) | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.