demo/script/main.js
function bind(element, properties) {
    var bindings = Object.keys(properties).filter(function (name) {
      var property = properties[name];
      if (Object.prototype.hasOwnProperty.call(property, 'statePath')) {
        if (!property.readOnly && property.notify) {
          console.warn('PolymerRedux: <' + element.constructor.is + '>.' + name + ' has "notify" enabled, two-way bindings goes against Redux\'s paradigm');
        }
        return true;
      }
      return false;
    });

    /**
     * Updates an element's properties with the given state.
     *
     * @private
     * @param {Object} state
     */
    var update = function update(state) {
      var propertiesChanged = false;
      bindings.forEach(function (name) {
        // Perhaps .reduce() to a boolean?
        var statePath = properties[name].statePath;

        var value = typeof statePath === 'function' ? statePath.call(element, state) : (0, _path.get)(state, statePath);

        var changed = element._setPendingPropertyOrPath(name, value, true);
        propertiesChanged = propertiesChanged || changed;
      });
      if (propertiesChanged) {
        element._invalidateProperties();
      }
    };

    // Redux listener
    var unsubscribe = store.subscribe(function () {
      var detail = store.getState();
      update(detail);

      element.dispatchEvent(new window.CustomEvent('state-changed', { detail: detail }));
    });

    subscribers.set(element, unsubscribe);

    return update(store.getState());
  }
function bind(element, properties) {
    var bindings = Object.keys(properties).filter(function (name) {
      var property = properties[name];
      if (Object.prototype.hasOwnProperty.call(property, 'statePath')) {
        if (!property.readOnly && property.notify) {
          console.warn('PolymerRedux: <' + element.constructor.is + '>.' + name + ' has "notify" enabled, two-way bindings goes against Redux\'s paradigm');
        }
        return true;
      }
      return false;
    });

    /**
     * Updates an element's properties with the given state.
     *
     * @private
     * @param {Object} state
     */
    var update = function update(state) {
      var propertiesChanged = false;
      bindings.forEach(function (name) {
        // Perhaps .reduce() to a boolean?
        var statePath = properties[name].statePath;

        var value = typeof statePath === 'function' ? statePath.call(element, state) : (0, _path.get)(state, statePath);

        var changed = element._setPendingPropertyOrPath(name, value, true);
        propertiesChanged = propertiesChanged || changed;
      });
      if (propertiesChanged) {
        element._invalidateProperties();
      }
    };

    // Redux listener
    var unsubscribe = store.subscribe(function () {
      var detail = store.getState();
      update(detail);

      element.dispatchEvent(new window.CustomEvent('state-changed', { detail: detail }));
    });

    subscribers.set(element, unsubscribe);

    return update(store.getState());
  }
function bind ( element , properties ) { var bindings = Object . keys ( properties ) . filter ( function ( name ) { var property = properties [ name ] ; if ( Object . prototype . hasOwnProperty . call ( property , 'statePath' ) ) { if ( ! property . readOnly && property . notify ) { console . warn ( 'PolymerRedux: <' + element . constructor . is + '>.' + name + ' has "notify" enabled, two-way bindings goes against Redux\'s paradigm' ) ; } return true ; } return false ; } ) ; /**
     * Updates an element's properties with the given state.
     *
     * @private
     * @param {Object} state
     */ var update = function update ( state ) { var propertiesChanged = false ; bindings . forEach ( function ( name ) { // Perhaps .reduce() to a boolean? var statePath = properties [ name ] . statePath ; var value = typeof statePath === 'function' ? statePath . call ( element , state ) : ( 0 , _path . get ) ( state , statePath ) ; var changed = element . _setPendingPropertyOrPath ( name , value , true ) ; propertiesChanged = propertiesChanged || changed ; } ) ; if ( propertiesChanged ) { element . _invalidateProperties ( ) ; } } ; // Redux listener var unsubscribe = store . subscribe ( function ( ) { var detail = store . getState ( ) ; update ( detail ) ; element . dispatchEvent ( new window . CustomEvent ( 'state-changed' , { detail : detail } ) ) ; } ) ; subscribers . set ( element , unsubscribe ) ; return update ( store . getState ( ) ) ; }
Binds element's properties to state changes from the Redux store.

@example
const update = bind(el, props) // set bindings
update(state) // manual update

@private
@param {HTMLElement} element
@param {Object} properties
@return {Function} Update function.
Binds element s properties to state changes from the Redux store .