Skip to content

A Vuex plugin that enables you to save the state of your NativeScript app to the SharedPreferences on Android and NSUserDefaults on iOS via the Application Settings module

License

Notifications You must be signed in to change notification settings

Hey-Marvelous/ns-vuex-persist

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ns-vuex-persist

A Vuex plugin that enables you to save the state of your NativeScript app to the SharedPreferences on Android and NSUserDefaults on iOS via the Application Settings module

Installation

npm install --save ns-vuex-persist

Usage

One of the use cases for this package is to store the user session on native device storage. Import the module from "ns-vuex-persist" and pass an instance of it to vuex as a store plugin. The module takes an optional array param in order to filter the modules that need to be persisted.

import Vue from 'vue'
import Vuex from 'vuex'
import NSVuexPersist from 'ns-vuex-persist'

/** Store modules */
import session from './modules/session/'
import todo from './modules/todo/'

Vue.use(Vuex)

const store = new Vuex.Store({
  modules: { session },
  plugins: [NSVuexPersist(['session'])]
})

export default store

Details and mentions

ns-vuex-persist contains an implentation of the "Storage" interface provided by @championswimmer in vuex-persist . This class is called NativeStorage and wraps the NativeScript Application Settings module in order to save the state into SharedPreferences (android) or NSUserDefaults (iOS) instead of LocaleStorage (default target in vuex-persist for web project).

Todo

  • "Transpile" the module in TypeScript
  • Refactor code and folder structure
  • Make it a NativeScript plugin
  • Add tests

About

A Vuex plugin that enables you to save the state of your NativeScript app to the SharedPreferences on Android and NSUserDefaults on iOS via the Application Settings module

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%