yapplabs / ember-buffered-proxy

An Ember Proxy the enables change buffering
MIT License
166 stars 31 forks source link

The future of buffered-proxy #12

Closed amk221 closed 9 years ago

amk221 commented 9 years ago

I listened to the frontside podcast (June) and learned that ObjectPoxy's are on the way out of Ember.

Even after the move from two way bindings to one way bindings, buffered proxy's are still useful (e.g. to collect form data, which will eventually be transferred to a model).

How will this affect the ember-buffered-proxy project?

spectras commented 9 years ago

@amk221 do you have any links to that? I'm looking for a robust way to implement “delay changes until the user clicks save” and buffered-proxy looks exactly like what I need. Your comment scared me a little though.

krisselden commented 9 years ago

You can accomplish the same thing by snapshotting the data and delay applying the changes until the user saves. I've had success with this approach, by copying the data to a forked model and on saving the forked model, pushing the data back to the original model. This has the benefit of being able to rollback the model on a cancelled failed save (including the relationships).

I would suggest moving away from buffered-proxy.

spectras commented 9 years ago

Alright, thanks for answering so fast.

amk221 commented 9 years ago

Do you have a gist of the snapshotting technique? The thing I like about the buffered proxy technique is the ability to mix in a validator into the proxy and store meta info on it. Would this still be possible?

krisselden commented 9 years ago

This was a quick sample, it is kind of basic https://github.com/krisselden/draft-sample

amk221 commented 9 years ago

Thanks, bit of a shame to have to lose the nice applyChanges() which avoided having to manually transfer the properties.

krisselden commented 9 years ago

this sample code have utils or an addon that makes it easier, less code