Components, Data-Down-Actions-Up and oneWay binding

I am trying to write a component that uses a one-way binding to simulate the Data Down, Actions Up (DDAU) restrictions. This component exposes an input box to change the value in question, and a button which fires a different action.

After the value of the one-way binding is modified, it becomes ‘out-of-sync’ and will no longer update the underlying data. This clearly breaks the DDAU paradigm.

In my example jsfiddle, the button always changes the underlying data to ‘bar’, demonstrating this ‘out-of-sync’-ness by changing the data in the component and then clicking the button to fire the action.

Thanks for your consideration!

Disclaimer I took a quick look through and didn’t actually fix the fiddle.

  • Your input value binding is two way and I think it’s nuking your one way binding after it sets value.
  • I believe you need to use an Ember.Object for your model so it’s observable but I’m not 100% sure.
  • You’re using the controllers proxying behavior which will be deprecated moving forwards along with controllers in general.

Disclaimer: I’m relatively new to Ember

Thanks for taking a look, varblob. Can you help me understand what you mean by “you’re using the controllers proxying behavior”? I am aware of the shift away from controllers & templates towards route-based components in 2.0, but I can’t seem to see what part of my fiddle this applys to.

Thanks varblob!

@marclundgren Welcome to Ember!

In your example you don’t explicitly declare a controller so ember rigs up an ObjectController for you. You then access the models property directly in your templates ie instead of model.value you’re just using value. This is utilizing the proxying behavior of an ObjectController.

Another note is in the data down actions up world the deified path, praise tomster, still uses two way bindings for inputs. https://github.com/emberjs/rfcs/pull/15 search for input

If you’re trying to prepare yourself for 2.0 I highly recommend this gist https://gist.github.com/samselikoff/1d7300ce59d216fdaf97 included is an example of how to future proof your controllers.