Polymer Redux
Polymer bindings for Redux. Bind store state to properties and dispatch actions from within Polymer Elements.
Polymer is a modern library for creating Web Components within an application. Redux is a state container for managing predictable data. Binding the two libraries together allows developers to create powerful and complex applications faster and simpler. This approach allows the components you build with Polymer to be more focused on functionality than the applications state.
Installation
bower install --save polymer-redux
Example
// Create a Redux storeconst store = Redux // Create the PolymerRedux mixinconst ReduxMixin = // Bind Elements using the mixinPolymerElement static { return 'my-element' } { super; const state = this; } // Define your ElementcustomElements
Now MyElement
has a connection to the Redux store and can bind properties to
it's state and dispatch actions.
Documentation
See the documentation page: https://tur-nr.github.io/polymer-redux/docs.
API
PolymerRedux
new PolymerRedux(<store>)
store
Object, Redux store.
Returns a ReduxMixin
function.
Redux Mixin
These methods are available on the instance of the component, the element.
#getState()
Returns current store's state.
#dispatch(<name>, [args, ...])
name
String, action name in the actions list.arg...
*, Arguments to pass to action function.
Returns the action object.
#dispatch(<fn>)
fn
Function, Redux middleware dispatch function.
Returns the action object.
#dispatch(<action>)
action
Object, the action object.
Returns the action object.
Events
state-changed
Fires when the store's state has changed.
License
Copyright (c) 2017 Christopher Turner