@huds0n/shared-state-store-rn
v2.0.0-beta1
Published
Share States React Native store creator
Downloads
22
Maintainers
Readme
📝 Table of Contents
🧐 About
Add state persisting to React Native projects using the @huds0n/shared-state module.
✅ List of Features
- Quick: Initialize a store in a single line.
- Secure: Built in AES encryption.
- Specific: Use include/exclude keys to specify which props to save.
- Automatic: Have state save on background or after change.
🏁 Getting Started
Prerequisites
Requires huds0n/shared-state and @react-native-async-storage/async-storage.
Installing
npm i @huds0n/shared-state-store-rn
🧑💻 Usage
Persist a Shared State
import { SharedState } from "@huds0n/shared-state";
const ExampleState = new SharedState({
username: null,
password: null
...ect
});
ExampleState.initializeStorage(
createStoreRN(storeOptions),
);
Returns a promise that resolve with true/false depending on success.See reference for storeOptions.
📖 Reference
Store Options
| Prop | Required/(Default) | Description | Type | | ----------------- | :------------------: | ---------------------------------------------------------------------------------------------- | -------------------------------------- | | encryptionKey | - | AES encryption stringStorage unencrypted if undefined | string | | excludeKeys | - | List of state props not to save | array of state keys | | includeKeys | - | List of state props to saveAll other state props skippedOverrides excludeKeys prop | array of state keys | | replacer | - | Replacer function used in stringifing the save state | (key: string, value: any) => any | | reviver | - | Reviver function used in parse the save state | (key: string, value: any) => any | | saveOnBackground | false | Saves state automatically when app is backgrounded | boolean | | saveAutomatically | false | Saves state automatically whenever state changes | boolean | | storeName | ✔ | name of store | string |
✍️ Authors
- @JontiHudson - Idea & Initial work
- @MartinHudson - Support & Development
See also the list of contributors who participated in this project.
🎉 Acknowledgements
- Special thanks to my fiance, Arma, who has been so patient with all my extra-curricular work.