Last active
July 28, 2021 22:32
-
-
Save DylanPiercey/e5edfe0ec9fb75f07267d3e7b70087e2 to your computer and use it in GitHub Desktop.
Local storage Tags API example
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
<local/count=0 storageKey="count"/> | |
<p>You clicked ${count} times</p> | |
<button onClick() { count++ }> | |
Click me | |
</button> |
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
<!-- local.marko --> | |
<attrs/{ default: initialValue, storageKey }/> | |
<const/stored=localStorage.getItem(storageKey)/> | |
<let/store=stored ? JSON.parse(stored) : initialValue/> | |
<effect() { localStorage.setItem(storageKey, JSON.stringify(store)) }/> | |
<return:=store/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment