Builds a custom storage that can be passed to LTM.
+Long Term Memory main class.
-Builds chrome.storage.local wrapper.
-Builds a storage wrapper for storages using the same API as chrome.storage.*.
-Key used to store the persisted state.
-The storage object (implementing chrome.storage.* API).
-Custom conversion from state object to storage object (default is pass through).
-Custom conversion from storage object to state object (default is pass through).
-Builds a storage wrapper for storages using the same API as chrome.storage.*.
+Key used to store the persisted state.
+The storage object (implementing chrome.storage.* API).
+Custom conversion from state object to storage object (default is pass through).
+Custom conversion from storage object to state object (default is pass through).
+Builds chrome.storage.sync wrapper.
-Deep merge the states using deepmerge library (defaults except that arrays are replaced).
-State that will be put into Vuex.
-See configurableDeepMerge for customizations.
-Builds storage that keeps the state only in memory (the same way Vuex does).
-Builds storage that keeps the state only in memory (the same way Vuex does).
+Builds LocalForage wrapper.
-Key used to store the persisted state.
+Builds LocalForage wrapper.
+Key used to store the persisted state.
Options to be passed to LocalForage.
-Optional
toInner: ToInner<Outer, Inner>Custom conversion from state object to storage object (default is pass through).
-Optional
toOuter: ToOuter<Outer, Inner>Custom conversion from storage object to state object (default is pass through).
-Optional
toInner: ToInner<Outer, Inner>Custom conversion from state object to storage object (default is pass through).
+Optional
toOuter: ToOuter<Outer, Inner>Custom conversion from storage object to state object (default is pass through).
+Builds a storage wrapper for storages using the same API as LocalForage.
-Key used to store the persisted state.
-The storage object (implementing LocalForage API).
-Custom conversion from state object to storage object (default is pass through).
-Custom conversion from storage object to state object (default is pass through).
-Builds a storage wrapper for storages using the same API as LocalForage.
+Key used to store the persisted state.
+The storage object (implementing LocalForage API).
+Custom conversion from state object to storage object (default is pass through).
+Custom conversion from storage object to state object (default is pass through).
+Builds localStorage wrapper.
-Builds localStorage wrapper.
+Builds a storage wrapper for storages using the same API as localStorage.
-Key used to store the persisted state.
+Builds a storage wrapper for storages using the same API as localStorage.
+Key used to store the persisted state.
The storage object (implementing localStorage API).
-Custom conversion from state object to string (default is JSON.stringify).
-Custom conversion from string to state object (default is JSON.parse).
-Custom conversion from state object to string (default is JSON.stringify).
+Custom conversion from string to state object (default is JSON.parse).
+Discard the previous state and use the loaded one.
+State that will be put into Vuex.
+Discard the previous state and use the loaded one.
+State just loaded from the storage.
+State that will be put into Vuex.
+Builds sessionStorage wrapper.
-Builds sessionStorage wrapper.
+Async modular persistence for Vuex store.
+Async modular persistence for Vuex store.
Documentation: https://thomaash.github.io/vuex-ltm/
-import Vue from "vue"
import Vuex from "vuex"
import {
LTM,
dummyFilter,
localStorageWrapper,
replace,
saveAll,
simplyExecute
} from "vuex-ltm"
const ltm = new LTM({
// Persist immediatelly (even multiple times per second).
execute: simplyExecute,
// Persist all mutations.
filter: dummyFilter,
// Replace the state in Vuex when loading.
merge: replace,
// Persist the whole state.
reduce: saveAll,
// Persist into the localStorage as the 'app-state' item.
storage: localStorageWrapper("app-state", localStorage)
})
Vue.use(Vuex)
const store = new Vuex.Store({
state: {},
plugins: [ltm.plugin]
})
+Simple example
import Vue from "vue"
import Vuex from "vuex"
import {
LTM,
dummyFilter,
localStorageWrapper,
replace,
saveAll,
simplyExecute
} from "vuex-ltm"
const ltm = new LTM({
// Persist immediatelly (even multiple times per second).
execute: simplyExecute,
// Persist all mutations.
filter: dummyFilter,
// Replace the state in Vuex when loading.
merge: replace,
// Persist the whole state.
reduce: saveAll,
// Persist into the localStorage as the 'app-state' item.
storage: localStorageWrapper("app-state", localStorage)
})
Vue.use(Vuex)
const store = new Vuex.Store({
state: {},
plugins: [ltm.plugin]
})
-Better example
import Vue from 'vue'
import Vuex from 'vuex'
import {
LTM,
chromeSyncStorage,
deepMerge,
executeWithDelay,
localStorage,
mutationFilter,
pickModules
} from 'vuex-ltm'
const ltm = new LTM({
// Persist 2 seconds after the last change (prevents bursts).
execute: executeWithDelay(2000),
// Persist only after select mutations.
filter: mutationFilter(['mutation-type-1', 'mutation-type-2']),
// Merge the persisted state with the defaults in Vuex.
merge: deepMerge,
// Persist only some modules.
reduce: pickModules(['sync']),
// Persist into the chrome.storage.sync if in extension or into localStorage otherwise (dev/demo).
storage: chrome && chrome.storage && chrome.storage.sync
? chromeSyncStorage('app-state')
: localStorage('app-state'),
})
Vue.use(Vuex)
const store = new Vuex.Store({
state: {},
modules: {
local: …,
sync: …
},
plugins: [ltm.plugin]
})
// You can also wait for the persisted state to be loaded (preferably with some nice spinner or something).
// Otherwise you'll have the defaults in Vuex before the persisted state is loaded.
;(async () => {
await ltm.ready
new Vue({
store,
render: h => h(App)
}).$mount('#app')
})()
+Better example
import Vue from 'vue'
import Vuex from 'vuex'
import {
LTM,
chromeSyncStorage,
deepMerge,
executeWithDelay,
localStorage,
mutationFilter,
pickModules
} from 'vuex-ltm'
const ltm = new LTM({
// Persist 2 seconds after the last change (prevents bursts).
execute: executeWithDelay(2000),
// Persist only after select mutations.
filter: mutationFilter(['mutation-type-1', 'mutation-type-2']),
// Merge the persisted state with the defaults in Vuex.
merge: deepMerge,
// Persist only some modules.
reduce: pickModules(['sync']),
// Persist into the chrome.storage.sync if in extension or into localStorage otherwise (dev/demo).
storage: chrome && chrome.storage && chrome.storage.sync
? chromeSyncStorage('app-state')
: localStorage('app-state'),
})
Vue.use(Vuex)
const store = new Vuex.Store({
state: {},
modules: {
local: …,
sync: …
},
plugins: [ltm.plugin]
})
// You can also wait for the persisted state to be loaded (preferably with some nice spinner or something).
// Otherwise you'll have the defaults in Vuex before the persisted state is loaded.
;(async () => {
await ltm.ready
new Vue({
store,
render: h => h(App)
}).$mount('#app')
})()
-License
This project is dual licensed under Apache 2.0 and ISC. Pick whichever you like more.
+License
This project is dual licensed under Apache 2.0 and ISC. Pick whichever you like more.
Async modular persistence for Vuex store.
Documentation: https://thomaash.github.io/vuex-ltm/
-Simple example
import Vue from "vue"
import Vuex from "vuex"
import {
LTM,
dummyFilter,
localStorageWrapper,
replace,
saveAll,
simplyExecute
} from "vuex-ltm"
const ltm = new LTM({
// Persist immediatelly (even multiple times per second).
execute: simplyExecute,
// Persist all mutations.
filter: dummyFilter,
// Replace the state in Vuex when loading.
merge: replace,
// Persist the whole state.
reduce: saveAll,
// Persist into the localStorage as the 'app-state' item.
storage: localStorageWrapper("app-state", localStorage)
})
Vue.use(Vuex)
const store = new Vuex.Store({
state: {},
plugins: [ltm.plugin]
})
+Simple example
import Vue from "vue"
import Vuex from "vuex"
import {
LTM,
dummyFilter,
localStorageWrapper,
replace,
saveAll,
simplyExecute
} from "vuex-ltm"
const ltm = new LTM({
// Persist immediatelly (even multiple times per second).
execute: simplyExecute,
// Persist all mutations.
filter: dummyFilter,
// Replace the state in Vuex when loading.
merge: replace,
// Persist the whole state.
reduce: saveAll,
// Persist into the localStorage as the 'app-state' item.
storage: localStorageWrapper("app-state", localStorage)
})
Vue.use(Vuex)
const store = new Vuex.Store({
state: {},
plugins: [ltm.plugin]
})
-Better example
import Vue from 'vue'
import Vuex from 'vuex'
import {
LTM,
chromeSyncStorage,
deepMerge,
executeWithDelay,
localStorage,
mutationFilter,
pickModules
} from 'vuex-ltm'
const ltm = new LTM({
// Persist 2 seconds after the last change (prevents bursts).
execute: executeWithDelay(2000),
// Persist only after select mutations.
filter: mutationFilter(['mutation-type-1', 'mutation-type-2']),
// Merge the persisted state with the defaults in Vuex.
merge: deepMerge,
// Persist only some modules.
reduce: pickModules(['sync']),
// Persist into the chrome.storage.sync if in extension or into localStorage otherwise (dev/demo).
storage: chrome && chrome.storage && chrome.storage.sync
? chromeSyncStorage('app-state')
: localStorage('app-state'),
})
Vue.use(Vuex)
const store = new Vuex.Store({
state: {},
modules: {
local: …,
sync: …
},
plugins: [ltm.plugin]
})
// You can also wait for the persisted state to be loaded (preferably with some nice spinner or something).
// Otherwise you'll have the defaults in Vuex before the persisted state is loaded.
;(async () => {
await ltm.ready
new Vue({
store,
render: h => h(App)
}).$mount('#app')
})()
+Better example
import Vue from 'vue'
import Vuex from 'vuex'
import {
LTM,
chromeSyncStorage,
deepMerge,
executeWithDelay,
localStorage,
mutationFilter,
pickModules
} from 'vuex-ltm'
const ltm = new LTM({
// Persist 2 seconds after the last change (prevents bursts).
execute: executeWithDelay(2000),
// Persist only after select mutations.
filter: mutationFilter(['mutation-type-1', 'mutation-type-2']),
// Merge the persisted state with the defaults in Vuex.
merge: deepMerge,
// Persist only some modules.
reduce: pickModules(['sync']),
// Persist into the chrome.storage.sync if in extension or into localStorage otherwise (dev/demo).
storage: chrome && chrome.storage && chrome.storage.sync
? chromeSyncStorage('app-state')
: localStorage('app-state'),
})
Vue.use(Vuex)
const store = new Vuex.Store({
state: {},
modules: {
local: …,
sync: …
},
plugins: [ltm.plugin]
})
// You can also wait for the persisted state to be loaded (preferably with some nice spinner or something).
// Otherwise you'll have the defaults in Vuex before the persisted state is loaded.
;(async () => {
await ltm.ready
new Vue({
store,
render: h => h(App)
}).$mount('#app')
})()
-License
This project is dual licensed under Apache 2.0 and ISC. Pick whichever you like more.
-
This project is dual licensed under Apache 2.0 and ISC. Pick whichever you like more.
+Storage interface that can be passed to LTM.
-Valid storage can also be built using GenericStorageWrapper.
-Storage interface that can be passed to LTM.
+Valid storage can also be built using GenericStorageWrapper.
+Required subset of localStorage API by localStorageWrapper.
-Required subset of localStorage API by localStorageWrapper.
+Manages execution of passed functions (e.g. avoiding bursts by skipping some).
-Function to be executed (may be thrown away and never executed).
-Manages execution of passed functions (e.g. avoiding bursts by skipping some).
+Function to be executed (may be thrown away and never executed).
+Decides if given mutation should trigger persisting.
-The mutation from Vuex.
+Decides if given mutation should trigger persisting.
+The mutation from Vuex.
True to persist, false to ignore.
-Handles persisted state loading.
-Handles persisted state loading.
+Merges state loaded from the storage with the one present in Vuex.
-Merges state loaded from the storage with the one present in Vuex.
+Handles state persisting.
-Handles state persisting.
+Converts outer state (used in Vuex) to inner state (persisted), e.g. JSON.stringify(…).
-Converts outer state (used in Vuex) to inner state (persisted), e.g. JSON.stringify(…).
+Converts inner state (persisted) to outer state (used in Vuex), e.g. JSON.parse(…).
-Converts inner state (persisted) to outer state (used in Vuex), e.g. JSON.parse(…).
+Const
Const
Builds a custom storage that can be passed to LTM.
-Typeparam
Outer - The Vuex state type.
-Typeparam
Inner - The storage state type.
-