Polymer / polycasts

Other
220 stars 134 forks source link

define thunk behavior with polymer 2.0 classes #18

Closed togonow closed 7 years ago

togonow commented 7 years ago

How to define a redux thunk that can be mixed in (used to be in the behavior array) with the new polylmer 2.0 elements.

togonow commented 7 years ago

the example in the documentation uses thunk within the element as below. i'm trying to separate the logic from the polymer element `class DemoApp extends ReduxMixin(Polymer.Element) { // ...

connectedCallback() { super.connectedCallback();

// Update message using Redux Thunk
this.dispatch((dispatch) => {
  dispatch('updateMessage', 'Please wait...');

  // Do async task
  setTimeout(() => {
    dispatch('updateMessage', 'Sorry for being late!');
  }, 1000);
});

} }`

johnthad commented 7 years ago

See my update to Polycast 62 for how I did it: https://github.com/johnthad/polycast62 and read this excellent post on mixins by Justin Fagini.

(My Polycast 61 is here https://github.com/johnthad/polycast62)

togonow commented 7 years ago

Thank you soo much

zmeireles commented 7 years ago

Awesome!