-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Improve storage and add sessionStorage and webStorage (#98)
* feat: improve accessing storage and added webStorage, sessionStorage * add tab sync functionality to storage * Added documentation * webstorage testing * added sessionStorage tests * more tests * remove comment * add string typing when using storage * add image to localStorage.md
- Loading branch information
Showing
31 changed files
with
1,316 additions
and
343 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,50 @@ | ||
<template> | ||
<div> | ||
localStorage: {{storage}} | ||
localStorage: {{ storage }} | ||
<p> | ||
<b>Check the value in the dev tools: `{{key}}`</b> | ||
supported: | ||
<b :class="{ green: supported, red: !supported }">{{ supported }}</b> | ||
</p> | ||
<p> | ||
<b>Check the value in the dev tools: `{{ key }}`</b> | ||
</p> | ||
<label for="storage"> | ||
<input name="storage" v-model="storage" /> | ||
</label> | ||
|
||
<div> | ||
<p>Enable tab sync? <input type="checkbox" v-model="tabSync" /></p> | ||
<p v-if="tabSync"> | ||
Now this tab is listening for changes, please change the storage value | ||
in other tab | ||
</p> | ||
</div> | ||
<div> | ||
<button @click="remove">Remove</button> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { useLocalStorage } from "vue-composable"; | ||
import { ref, watch } from "@vue/composition-api"; | ||
export default { | ||
name: "local-storage-example", | ||
setup() { | ||
const key = "__vue_localStorage_example"; | ||
const { storage } = useLocalStorage(key, 1); | ||
const tabSync = ref(false); | ||
const { supported, storage, setSync, remove } = useLocalStorage(key, 1); | ||
watch(tabSync, setSync); | ||
return { | ||
key, | ||
storage | ||
supported, | ||
tabSync, | ||
storage, | ||
remove | ||
}; | ||
} | ||
}; | ||
</script> | ||
</script> |
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 |
---|---|---|
|
@@ -21,11 +21,3 @@ export default { | |
} | ||
}; | ||
</script> | ||
<style> | ||
.red { | ||
color: red; | ||
} | ||
.green { | ||
color: green; | ||
} | ||
</style> |
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,41 @@ | ||
<template> | ||
<div> | ||
sessionStorage: {{ storage }} | ||
<p> | ||
supported: | ||
<b :class="{ green: supported, red: !supported }">{{ supported }}</b> | ||
</p> | ||
<p> | ||
<b>Check the value in the dev tools: `{{ key }}`</b> | ||
</p> | ||
<label for="storage"> | ||
<input name="storage" v-model="storage" /> | ||
</label> | ||
|
||
<div> | ||
<button @click="remove">Remove</button> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { useSessionStorage } from "vue-composable"; | ||
import { ref, watch } from "@vue/composition-api"; | ||
export default { | ||
name: "session-storage-example", | ||
setup() { | ||
const key = "__vue_sessionStorage_example"; | ||
const tabSync = ref(false); | ||
const { supported, storage, remove } = useSessionStorage(key, 1); | ||
return { | ||
key, | ||
supported, | ||
tabSync, | ||
storage, | ||
remove | ||
}; | ||
} | ||
}; | ||
</script> |
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,59 @@ | ||
<template> | ||
<div> | ||
storage: {{ storage }} | ||
<p> | ||
supported: | ||
<b :class="{ green: supported, red: !supported }">{{ supported }}</b> | ||
</p> | ||
<p> | ||
<b>Check the value in the dev tools: `{{ key }}`</b> | ||
</p> | ||
<label for="storage"> | ||
<input name="storage" v-model="storage" /> | ||
</label> | ||
|
||
<div> | ||
<p>Sync supported: {{ supportedSync }}</p> | ||
<p>Enable tab sync? <input type="checkbox" v-model="tabSync" /></p> | ||
<p v-if="tabSync"> | ||
Now this tab is listening for changes, please change the storage value | ||
in other tab | ||
</p> | ||
</div> | ||
<div> | ||
<button @click="remove">Remove</button> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { useLocalStorage, useStorage } from "vue-composable"; | ||
import { ref, watch } from "@vue/composition-api"; | ||
export default { | ||
name: "storage-example", | ||
setup() { | ||
const key = "__vue_storage_example"; | ||
const tabSync = ref(false); | ||
const supportedSync = ref(true); | ||
const { supported, storage, setSync, remove } = useStorage(key, 1); | ||
watch(tabSync, s => { | ||
if (setSync(s) === false) { | ||
supportedSync.value = false; | ||
} | ||
}); | ||
return { | ||
key, | ||
supported, | ||
supportedSync, | ||
tabSync, | ||
storage, | ||
remove | ||
}; | ||
} | ||
}; | ||
</script> |
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,7 @@ | ||
|
||
.red { | ||
color: red; | ||
} | ||
.green { | ||
color: green; | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.