lastmjs/redux-store-element

Instead of `on-statechange`, see if you can just databind the listener function into the element

Closed this issue · 1 comments

The on-statechange event has some undesirable qualities. The biggest is that the parameter passed into the listener function is an event, and you have to go down a couple levels to actually get to the state. This makes it so that we have to create another TypeScript interface just to describe this kind of event. It would be a lot better if the first parameter to the listener function was just the state. To do this, we could just databind the listener function into the element. But, the last time I tried to databind class member methods into Polymer elements, everything exploded. I had a discussion with members of the Polymer team, and they don't seem to think this use case is valid without additional boillerplate code that doesn't make sense to me. Maybe I'll petition them again, or maybe Polymer 2 has fixed the issues.

Actually, though Polymer 2 would allow us to data-bind a function, I don't think it would help that much. Events are easy to work with and make sense to most web developers...they are idiomatic. Binding a function is not as idiomatic I would say, and I don't see a compelling enough reason to do that here.