SteveSanderson / knockout-es5

Knockout.js meets ECMAScript 5 properties
157 stars 39 forks source link

Supply custom bindings with actual observables #15

Closed CraigCav closed 9 years ago

CraigCav commented 10 years ago

As discussed in issue #2, when using the es5 plugin, bindings aren't provided with the observable, only with the value of the property.

@rniemeyer suggested an approach to using a custom binding provider to supply bindings with actual observables. This approach should in theory support any existing two-way custom bindings developers may have written for knockout before applying the es5 plugin.

This PR is an attempt at implementing such a provider.

SteveSanderson commented 9 years ago

Thanks for suggesting this. Sorry it's literally taken a year for me to get back to maintaining this repo - I'm currently adding some new committers so the repo can progress independently of me.

About this new binding provider - is it something you're still using? Unlike the rest of knockout-es5, this binding provider ties in with quite a lot of KO binding internals, so it's going to require ongoing attention as KO changes or gains new binding features. It won't stay maintained on its own. I don't know whether it's currently up-to-date with the latest KO (3.2.0). So if it's still a going concern for you, then I propose two possible ways of going forwards:

Let me know what you prefer. Thanks!

CraigCav commented 9 years ago

About this new binding provider - is it something you're still using?

Unfortunately my usage of the es5 plugin never really got off the ground, and in turn, I never got to put this binding provider through its paces.

I don't know whether it's currently up-to-date with the latest KO (3.2.0).

The only piece i'm not sure about is that there was some discussion about making a public property writers API. As far as I'm aware, there still isn't an officially supported API for this. If there were, I guess this Binding Provider wouldn't be needed (although all our existing custom two-way bindings would need to be updated accordingly).

Let me know what you prefer. Thanks!

I'm happy to keep maintaining this binding provider, either as part of the core plugin or as a separate one.

In my perspective, I think it makes sense for this behavior to be part of the es5 plugin itself; I personally couldn't get too far with the es5 plugin on it's own (i.e without this change) due to the extensive usage of custom two-way bindings in my knockout-based projects.