Closed tur-nr closed 7 years ago
Looks perfect! Thanks for adding this feature. I'll work with this branch and give you any feedback if I find anything.
👍
@tur-nr found one issue. Actions defined in behaviors
are not picked up by the async dispatcher. I'll dig into it and see if I can patch it.
Here is a fix to extract actions from behaviors in the dispatchReduxAction
method. It should probably not override the actions defined in the root element as this quick fix does, but works though.
function dispatchReduxAction(element, store, args) {
var action = args[0];
var actions = element.actions;
// Quick fix: Extract actions from attached behaviors
element.behaviors.forEach(function(behavior) {if (behavior.actions) {
Object.assign(actions, behavior.actions);
}});
args = castArgumentsToArray(args);
...
@kristfal this will merge the behaviors actions into the elements, and will do so every time a dispatch is called on that element. It would be best not to merge I think.
@cvanleeuwen @kristfal
I have the dispatch passing the polymer-redux dispatch through to middleware actions. This allows you to make use of the action creators list on an element or dispatch any other valid redux action.
Here is a simple implementation, see
async.html
for a working demo.Also I want to note that dispatch functions that return an action (inline action creator) will be depreciated. It's a little confusing and makes me anxious 😟