# lspi-flux

> LocalStorage Based Flux/Store

Latest version **1.0.53** (published 2016-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install lspi-flux
pnpm add lspi-flux
yarn add lspi-flux
bun add lspi-flux
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.53 |
| Published | 2016-09-09 |
| First published | 2016-08-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | selfup |
| Maintainers | selfup |
| Keywords | flux, redux, localStorage, local storage, selfup, rejs |

## Links

- npm: https://www.npmjs.com/package/lspi-flux
- Repository: https://github.com/selfup/lspi-flux
- Issues: https://github.com/selfup/lspi-flux
- npm.io page: https://npm.io/package/lspi-flux

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 1.0.53 (latest) — 2016-09-09
- 1.0.52 — 2016-09-09
- 1.0.51 — 2016-09-05
- 1.0.5 — 2016-09-05
- 1.0.4 — 2016-09-02
- 1.0.3 — 2016-09-02
- 1.0.1 — 2016-08-26
- 1.0.0 — 2016-08-26

## README

# Stateful Store

### Developer Use

Currently the main API methods are:

```javascript
const LspiFlux = require('lspi-flux')
const lf       = new LspiFlux()

// this will make an LspiFlux object with the following defaults
// LspiFlux {storeName: "lspi-flux", mainStore: {}}

lf.fetchState 

// if all goes well this will return {status: true, state: {}} ->
lf.fetchState.state // {}
lf.fetchState.status // true

// if localStorage fails, this will return the state in memory before writing to localStorage
// it will also return a 'status' of false to help handle errors

const someObject = {wow: "wow"}
lf.setState(someObject) // this will return the same object as fetchState

// but the state here will be updated if nothing went wrong
// otherwise, handle the error by checking for a flase status


// if all goes well this will return {status: true, state: {wow: "wow"}} ->
lf.setState(someObject).state // {wow: "wow"}
lf.setState(someObject).status // true

// say you want to name the store and set a default value yourself ->
const ideas = new LspiFlux({}, 'ideas')

ideas.setState([{wow: "ok"}, {wow: "ok"}, {wow: "nope"}])

/***
whereState will return an object with two keys
  status:
  match:

this does not return the objects state
instead it returns the match of objects wrapped in an array if there are any
***/ // ->
const okResult = ideas.whereState('wow', 'ok')
const okMatch  = okResult.match

okResult.state // true
okResult.match // [{wow: "ok"}, {wow: "ok"}]
// okMatch -> [{wow: "ok"}, {wow: "ok"}]

const nopeResult = ideas.whereState('wow', 'nope')
const nopeMatch  = nopeResult.match

nopeResult.state // true
nopeResult.match // [{wow: "nope"}]
// nopeMatch -> [{wow: "nope"}]

// this is all that this library offers for the moment
// but a lot can be done to handle state with these three simple methods

// Enjoy!
```

### Current tests

![](http://i.imgur.com/CeCNnJK.png)

### Contributor Setup

Go to either: https://github.com/selfup/lspi-flux

Or:           https://gitlab.com/selfup/lspi-flux

*Clone one of them and:*

```
npm install
```

### To run the tests:

```
npm start
```

Then go to: http://localhost:8080/webpack-dev-server/test.html

### TODO

* Write more Documentation
* Ask for feedback about the API

---
_Source: https://npm.io/package/lspi-flux · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
