# redux-container-state-saga

> Enables redux-saga to handle local-only side effects

Latest version **0.4.0** (published 2016-06-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-container-state-saga
pnpm add redux-container-state-saga
yarn add redux-container-state-saga
bun add redux-container-state-saga
```

## 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.4.0 |
| Published | 2016-06-28 |
| First published | 2016-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=5.0.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Hans De Potter |
| Maintainers | hansdp |
| Keywords | redux, redux-elm, redux-saga, saga, elm, flux, side effects, local state, container state |

## Links

- npm: https://www.npmjs.com/package/redux-container-state-saga
- Repository: https://github.com/HansDP/redux-container-state-saga
- Issues: https://github.com/HansDP/redux-container-state-saga/issues
- npm.io page: https://npm.io/package/redux-container-state-saga

## Dependencies (3)

- [react](https://npm.io/package/react.md) ^15.1.0
- [redux-saga](https://npm.io/package/redux-saga.md) ^0.10.5
- [redux-container-state](https://npm.io/package/redux-container-state.md) ^0.4.0

## 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

- 0.4.0 (latest) — 2016-06-28
- 0.3.1 — 2016-06-27
- 0.1.5 — 2016-06-24
- 0.1.4 — 2016-06-24
- 0.1.3 — 2016-06-24
- 0.1.2 — 2016-06-24

## README

# [redux-container-state-saga](https://github.com/HansDP/redux-container-state-saga)

**Note:** Work in progress. This project is not ready to be used

Provides local saga middleware for containers in [redux-container-state](https://github.com/HansDP/redux-container-state)

This package encapsulates `redux-saga` to be used within the local scope of a container.

This solution does not allow access to global actions or state, but we're working on that.

## Example usage

```javascript
import React from 'react'
import { view, applyLocalMiddleware } from 'redux-container-state'
import { takeEvery, delay } from 'redux-saga'
import { put } from 'redux-saga/effects'

import sagaViewEnhancer from 'redux-container-state-saga'

// Our worker Saga: will perform the async increment task
function* incrementAsync() {
  yield delay(1000)
  yield put({ type: 'INCREMENT_COUNTER' })
}

// Our watcher Saga: spawn a new incrementAsync task on each INCREMENT_ASYNC
function* watchIncrementAsync() {
  yield* takeEvery('INCREMENT_SAGA', incrementAsync)
}

const counterUpdater = updater((model = 0, action) => {
  switch (action.type) {
    case 'INCREMENT_COUNTER': 
      return model + 1
    default:
      return model
  }
})

const viewWithMiddleware = compose(sagaViewEnhancer(watchIncrementAsync))(view)

export default viewWithMiddleware(({model, dispatch}) => (
  <div>
    <button onClick={ () => dispatch({ type: 'INCREMENT_SAGA' }) }>Start counter</button>
    Current count: { model }
  </div>
))

```

## Installation & Usage

You can install `redux-container-state-saga` via npm.

```
npm install redux-container-state-saga --save
```

## Requires investigation

1. Is it OK to have redux-saga to be attached to every view? 
2. What is the performance cost for setting up saga per view?  

If the above are problematic, 

1. Can we make a 'global' repository for sagas when are then behind the scenes redirected back to the appropriate container? 
2. Should we have the saga middleware applied to the global store? -- but this defaets being 'local'

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