# simple-ducks-builders

> simple redux ducks module builders

Latest version **0.1.7** (published 2019-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-ducks-builders
pnpm add simple-ducks-builders
yarn add simple-ducks-builders
bun add simple-ducks-builders
```

## 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.1.7 |
| Published | 2019-05-24 |
| First published | 2018-08-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 263.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | rkovalyov, rrott, sergey.sign, vsych |
| Keywords | redux, ducks |

## Links

- npm: https://www.npmjs.com/package/simple-ducks-builders
- Repository: https://github.com/cater2me/simple-ducks-builders
- Homepage: https://github.com/cater2me/simple-ducks-builders#readme
- Issues: https://github.com/cater2me/simple-ducks-builders/issues
- npm.io page: https://npm.io/package/simple-ducks-builders

## Dependencies (6)

- [react](https://npm.io/package/react.md) ^16.4.1
- [redux](https://npm.io/package/redux.md) ^4.0.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.10
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.1
- [prop-types](https://npm.io/package/prop-types.md) ^15.6.2
- [react-redux](https://npm.io/package/react-redux.md) ^5.0.7

## Recent versions

- 0.1.7 (latest) — 2019-05-24
- 0.1.6 — 2019-05-24
- 0.1.5 — 2019-05-24
- 0.1.4 — 2019-01-31
- 0.1.3 — 2019-01-24
- 0.1.2 — 2019-01-24
- 0.1.1 — 2019-01-24
- 0.1.0 — 2018-10-16
- 0.0.5 — 2018-08-31
- 0.0.4 — 2018-08-10
- 0.0.3 — 2018-08-09
- 0.0.2 — 2018-08-08

## README

# simple-ducks-builders

simple redux ducks module builders


## [simpleListBuilder](./docs/simpleListBuilder.md)

```coffee
# state.coffee

import {getList} from './dataProvider'
import {simpleListBuilder} from 'simple-ducks-builders'

MODULE = 'myList'

moduleBuilder = simpleListBuilder(MODULE)

export reducer = moduleBuilder.reducer
export actions = {
  loadList: -> moduleBuilder.actions.loadList(getList)
}
```

```coffee
# dataProvider.coffee
export getList = ->
  new Promise (resolve) -> resolve [{id:1, title:'a'},{id:2, title:'2'},]
```

container.coffee:
```coffee
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import {actions as myListActions} from './state'

class Container =
  componentDidMount: -> @props.actions.loadList()

  render: ->
    {isLoading, isReady, list} = @props.myListState
    return <span>loading</span> if isLoading || !isReady
    <div>
      {
        for item in list
          <div key={item.id}>{item.title}</div>
      }
    </div>

mapState = (state, ownProps) ->
  myListState: state.myList

mapActions = (dispatch, ownProps) ->
  actions: bindActionCreators myListActions, dispatch

export default connect(mapState, mapActions)(Container)

```


## [simpleFormBuilder](./docs/simpleFormBuilder.md)


```coffee
# state.coffee

import {simpleFormBuilder} from 'simple-ducks-builders'
MODULE_STATE_NAME = 'myItem'

formBuilder = simpleFormBuilder(MODULE_STATE_NAME)

loadItem = (id) ->
  formBuilder.actions.loadItem getItem.bind(null, id)
saveItem = formBuilder.actions.saveItem updateItem

export reducer = formBuilder.reducer
export actions = {
  loadItem,
  saveItem,
  setField: formBuilder.actions.setField
}
```

```coffee
# container.coffee

import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import {actions as myItemActions} from './state'

class Container =
  componentDidMount: ->
    @props.actions.loadItem(@props.id)

  render: ->
    {isLoading, isReady, inProgress, item} = @props.myItemState
    {setField, saveItem} = @props.actions
    return <span>loading</span> if isLoading || !isReady
    <div>
      <input
        value={item.title}
        onChange={(e) -> setField 'title', e.target.value}
        disabled={inProgress}
      />
      <button
        onClick={saveItem}
        disabled={!isChanged || inProgress}
      >Save</button>
    </div>

mapState = (state, ownProps) ->
  id: Number router.params.id
  myItemState: state.myItem

mapActions = (dispatch, ownProps) ->
  actions: bindActionCreators myItemActions, dispatch

export default connect(mapState, mapActions)(Container)

```

## [catchErrorsBuilder](./docs/catchErrorsBuilder.md)

## [selectItemBuilder](./docs/selectItemBuilder.md)

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