Store: 馃殌[FEATURE]: Proposal for ngxs/storage-plugin

Created on 6 Mar 2019  路  4Comments  路  Source: ngxs/store

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => https://github.com/ngxs/store/blob/master/CONTRIBUTING.md
[ ] Other... Please describe:

Current behavior

@State({
    name: 'filter',
    defaults: new Filter()
})
export class FilterState {
 // ..
}

not intuitive

NgxsStoragePluginModule.forRoot({ key: [..., 'filter'] })

Expected behavior

import { PersistenceState } from '@ngxs/storage-plugin';

@State({
    name: 'filter',
    defaults: new Filter()
})
@PersistenceState()
export class FilterState {
 // ..
}
NgxsStoragePluginModule.forRoot()

Full control flow for persist state

@PersistenceState({ name: 'key' })
@PersistenceState({ name: 'key', alias: 'keyAlias' })
@PersistenceState({ name: 'key', expiredTime: 100000 // ms })

@PersistenceState({ name: 'key', storage: 'localStorage' })
@PersistenceState({ name: 'key', storage: 'sessionStorage' })
@PersistenceState({ name: 'key', storage: 'indexDB' })
plugins low feature

Most helpful comment

All 4 comments

@splincode
I have a slightly related question, why not use localForage for the plugin?
It will enable IndexedDB by default and handle fallback when needed.

@YogliB hello, the problem is that we want to use several kinds of storages

I use ngxs data plugin for now

Was this page helpful?
0 / 5 - 0 ratings