@huds0n/shared-state-store-rn
TypeScript icon, indicating that this package has built-in type declarations

2.0.0-beta1 • Public • Published

@huds0n/shared-state-store-rn

Status GitHub Issues GitHub Pull Requests License


Add state persisting to @huds0n/shared-state using @react-native-async-storage/async-storage

📝 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

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.

Package Sidebar

Install

npm i @huds0n/shared-state-store-rn

Weekly Downloads

1

Version

2.0.0-beta1

License

MIT

Unpacked Size

19.2 kB

Total Files

15

Last publish

Collaborators

  • jonti_hudson