# reflux-store-cache-mixin

> Reflux store chaching mixin to reduce unnecessary calls

Latest version **0.0.5** (published 2015-07-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install reflux-store-cache-mixin
pnpm add reflux-store-cache-mixin
yarn add reflux-store-cache-mixin
bun add reflux-store-cache-mixin
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2015-07-06 |
| First published | 2015-07-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Caleb Morris |
| Maintainers | calebmorris |

## Links

- npm: https://www.npmjs.com/package/reflux-store-cache-mixin
- Repository: https://github.com/calebmorris/reflux-store-cache-mixin
- Homepage: https://github.com/calebmorris/reflux-store-cache-mixin#readme
- Issues: https://github.com/calebmorris/reflux-store-cache-mixin/issues
- npm.io page: https://npm.io/package/reflux-store-cache-mixin

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^3.10.0
- [moment](https://npm.io/package/moment.md) ^2.10.3
- [immutable](https://npm.io/package/immutable.md) ^3.7.4

## Recent versions

- 0.0.5 (latest) — 2015-07-06
- 0.0.4 — 2015-07-06
- 0.0.3 — 2015-07-06
- 0.0.2 — 2015-07-06
- 0.0.1 — 2015-07-06

## README

# reflux-store-cache-mixin

Reflux mixin for caching data.

Main usage is to reduce network calls for slowly changing data

# Example

```javascript

// Actions
import Reflux from 'reflux';

const testActions = Reflux.createActions({
  fetch: {
    children : [ 'completed', 'failed' ],
  },
});

export default testActions;

// Store
import Reflux from 'reflux';
import StoreCacheMixin from 'reflux-store-cache-mixin';
import { Map } from 'immutable';

export default Reflux.createStore({
  listenables : testActions,

  data : new Map(),

  mixins : [ StoreCacheMixin ],

  onFetch() {
      this.loadData('data', '*', (data, saveNewData) => {

        if (! data) {
          return fetchData()
            .tap(saveNewData)
            .then((nextData) => {
              this.data = nextData;
              return this.trigger(this.data);
            });
        }

        return this.trigger(this.data);

      });
  },
});


```

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