Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide example of using bufferedProxy on records with relationships #7

Open
lolmaus opened this issue Jan 21, 2015 · 6 comments
Open

Comments

@lolmaus
Copy link

lolmaus commented Jan 21, 2015

Hi! Thank you for you your awesome project.

I wonder whether i can use ember-buffered-proxy on Ember Data records.

My use case:

  1. A record is created clientside when a user visits the route. The record will eventually be persisted to the backend, but during this use case it does not.
  2. The user opens a modal dialog with an edit form, edits the record and presses OK in the form to close the dialog. From the user perspective, he has kinda saved his edits, and the record is now in state A.
  3. The user can open the form and edit the record again. The record is now is in state B. If he messes up, he should be able to discard his edits by pressing Cancel instead of OK. I cannot use .rollback() because it will revert the unsaved record to a tabula rasa state, while the user expects it to be reverted to state A.

My problem is that the record in question does not store much data itself: all its data comes from related child and grandchild records.

Does this mean that i have to apply discardBufferedChanges recursively? Is there a simpler way?

@lukemelia
Copy link
Contributor

I think the best way to model this would probably be to have a bufferedProxy per record, and apply or discard accordingly.

@lolmaus
Copy link
Author

lolmaus commented Apr 17, 2015

I struggle to figure out how to do that. Can you please provide an example?

I think using bufferedProxy on records is a popular use case and a publicly available example will be very useful.

@lukemelia
Copy link
Contributor

@lolmaus See also discussion in #9. I don't have time at the moment to create an example, but I'll reopen this to track that.

@lukemelia lukemelia reopened this Apr 17, 2015
@lukemelia lukemelia changed the title Using on Ember Data records? Provide example of using bufferedProxy on records with relationships Apr 17, 2015
@blimmer
Copy link
Contributor

blimmer commented Sep 21, 2015

This would be super helpful to have documentation on the preferred way to buffer changes to hasMany relationships.

@BenjaminHorn
Copy link

I am struggling to rollback a model (post), whit has many (comments) , where comment belongs to (author). An example would be great.

@remino
Copy link

remino commented Jan 31, 2016

Having an example on how to use this on a model would be great. I'm also struggling with this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants