-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polymer-redux 1.0 + Polymer 2 hybrid mode doesn't expose state + dispatch is unknown #87
Comments
Record-keeping: #89 probably further complicates use in the hybrid mode. |
Any update on this? We are using Polymer 2 but have elements currently in Polymer 2.x legacy mode. As such the behavior no longer works. Is there a workaround or do I need to downgrade version? Will 0.4.2 even work with Polymer 2? |
Here are the steps that we ended up taking:
It's not really ideal as we still had to change dozens of elements during the last step - but at least the last step was rather mechanical. |
Thanks @ronnyroeller. Simply downgrading to 0.4.2 seemed to work fine for me. Would still like an upgrade path however. |
The logic for property setting is different between v0 and v1 in PolymerRedux. I'm not so sure if it can be done without bringing some of the old logic from v0 across to v1. I would be happy to work with someone who knows how Hybrid elements work. From my own understanding the plan of action would be:
|
I think the best approach maybe would be to ping polymer team? @robdodson @tjsavage |
@kevinpschaaf may have some ideas. |
So if I understand, in That said, with the current construction of the PolymerRedux mixin, it looks possible to do it manually, if that's a solution for you. I did a proof of concept here: https://glitch.com/edit/#!/brick-raver?path=public/index.html:43:2 Basically, this code adds back the behavior-based interface to the mixin function, such that it can be used as a mixin on classes OR a behavior object in hybrid elements. const MixinFactory = PolymerRedux;
PolymerRedux = store => {
let curr;
const mixin = MixinFactory(store);
const base = mixin(class {
constructor() { return curr; }
connectedCallback() {}
disconnectedCakkback() {}
});
const behavior = {
created() {
curr = this;
new base();
curr = null;
},
attached: base.prototype.connectedCallback,
detached: base.prototype.disconnectedCallback,
dispatch: base.prototype.dispatch,
getState: base.prototype.getState,
registered() {
this.constructor.actions = this.actions;
}
};
return Object.assign(mixin, behavior);
}
...
// Can be used as a behavior OR a mixin
const ReduxMixinOrBehavior = PolymerRedux(store); It's a bit brittle/hacky, but something like this might work as a stop-gap solution for folks here. Alternatively, @tur-nr could just consider factoring the code in the mixin callbacks out into shared functions and provide an option to return a behavior that uses the shared code, to avoid needing to deal with |
@kevinpschaaf thank you very much. @tur-nr could you please add this as a behavior.htm in the project? |
It would be great if Polymer-redux would work not only with pure Polymer 2 (e.g. ES6 class syntax) but also with Polymer hybrid mode.
Right now, for hybrid element with the
PolymerRedux
behavior the Redux state isn't available and callingthis.dispatch
causes the following error:This issue can be replicated by running
demo/ready-state.html
after applying PR #86.The text was updated successfully, but these errors were encountered: