Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jkusa/ember-redux-helpers

A set of Ember Template Helpers for Redux.JS
https://github.com/jkusa/ember-redux-helpers

Last synced: 3 months ago
JSON representation

A set of Ember Template Helpers for Redux.JS

Awesome Lists containing this project

README

        

# ember-redux-helpers

[![Build Status](https://travis-ci.org/jkusa/ember-redux-helpers.svg?branch=master)](https://travis-ci.org/jkusa/ember-redux-helpers)

A set of [Ember](http://emberjs.com) Template Helpers for [Redux.JS](http://redux.js.org)

## Demo Page

http://jkusa.github.io/ember-redux-helpers/

## Usage

### `{{get-state "state.path"}}`

Helper to fetch and subscribe to state properties in the redux store

```hbs
{!-- component.hbs --}}
{{progress-bar
progress=(get-state 'progress')
}}
```

Use object paths just like you would with [Ember.get](http://emberjs.com/api/#method_get)

```hbs
{{!-- component.hbs --}}
{{todo-item
todo=(get-state 'todos.firstObject')
}}
```

### `{{dispatch "TYPE" key=value key=value}}`

Closure action helper to dispatch directly to the redux store

```hs
{{!-- component.hbs --}}

Click to Add

```

```js
//reducer.js
export default (state=0, action) => {

if(action.type === 'ADD') {
state += action.value;
}

return state;
};
```

Arguments provided while invoking the action can be referenced via the __invocationArgs__ property array

```hbs
{{!-- component.hbs --}}

```

```js
//reducer.js
export default (state={}, action) => {

if (action.type === 'UPDATE') {

let { field, invocationArgs } = action;
state = Object.assign(state, {
//invocaionArgs contains the event obj
[field]: invocationArgs[0].target.value
});

}

return state;
};
```

## Compatibility

This addon will work on Ember versions `1.13.x` and up only, due to use of the new `Helper` implementation.

## Thanks

Thanks to @toranb and @rwjblue who inspired this addon.