Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ember-buffered-proxy usage

This example is for an ember-data model named 'plan'.

Proxy creation can be done in a computed property in the controller/component. It won't re-compute unless the entire plan changes (properties on plan can change and it won't trigger this). And then we can use applyBufferedChanges inside of the actions hash save action.

  // controller plans/edit.js
  planProxy: computed('plan', function() {
    return BufferedProxy.create({content: this.get('plan')});
  actions: {
    savePlan() {

And then to keep things clear, a component can get along just fine with no awareness that there's a proxy involved.

// route template for plans/edit.hbs
  savePlan=(action 'savePlan')
// component template plan-edit.hbs

<button {{action savePlan}}>
  Save Plan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment