mediamonks / muban-core

The core library and webpack loaders for Muban
MIT License
0 stars 2 forks source link

Don't allow data-binding on the template itself #28

Open skulptur opened 4 years ago

skulptur commented 4 years ago

Since this is often used when we don't have complete control over the HTML, it is not a good idea to use knockout's template binding syntax. Only way to data bind should be via JS.

Proposed solution is to provide our own stripped down data-binding functionality instead of using knockout directly.

ThaNarie commented 4 years ago

How is this ticket different from the documentation already explaining this?

https://github.com/mediamonks/muban/blob/master/docs/08-knockout.md https://github.com/mediamonks/muban/blob/master/docs/13-guides.md#Knockout

skulptur commented 4 years ago

The issue is that explaining in the docs doesn't erase those features from knockout and it can still be abused. The more we can move from docs into the API the better.

ThaNarie commented 4 years ago

There are cases where using client-side knockout templates (purely defined in JS for example) would still be a valid use case (when going full embedded react is too much overkill).

So the reasoning for the current approach is that it's one (existing!) library that can be used for different cases:

  1. only for the observables/computeds - just like mobx
  2. additional do template bindings from JS, to make smal DOM updates easier
  3. introduce ko templates (compiled in JS) to make certain UI interactive that doesn't need to be rendered on the server, and/or receives data from XHR.

If you need all 3 cases in different areas in your project, you just need to learn and bundle 1 single library, making it a lot easier.

I'm open for alternatives, but we need to see how they solve the use cases above.