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

Creating "invalid" records in memory / triggering persistence #74

Closed
leejt489 opened this issue Nov 16, 2014 · 4 comments
Closed

Creating "invalid" records in memory / triggering persistence #74

leejt489 opened this issue Nov 16, 2014 · 4 comments

Comments

@leejt489
Copy link

How can we create a new record in Memory, bind it to a form, and then when all validations pass synchronize it with other sources? Something to do with blocking a transformation until a validation passes?

@leejt489
Copy link
Author

ember-data, for example, uses 'save' to persist data, but as far as I can tell orbit does not have a specific persist command.

@leejt489 leejt489 changed the title Creating "invalid" records in memory Creating "invalid" records in memory / triggering persistence Nov 16, 2014
@dgeb
Copy link
Member

dgeb commented Nov 17, 2014

Orbit takes a different approach from ember-data. In ember-data, records maintain state themselves. In orbit, the state of records exists exclusively in sources. In other words, orbit doesn't maintain temporary editing state in record objects which then need to be "saved".

I am working on a pattern in ember-orbit to create temporary sources that act as "editing contexts". The idea is that data is copied to a context, edited in isolation, and the operations are then squashed and applied back to the main source in a single transaction (or the context and its changes can be discarded). I think this is a more robust and clean approach to saving records transactionally. I'll be illustrating this pattern in the example project I've mentioned.

@leejt489
Copy link
Author

Makes sense, looking forward to seeing the pattern in the example project!

@dgeb
Copy link
Member

dgeb commented Jul 18, 2017

The concept of "editing contexts" has materialized as store forking and merging, as documented here: http://orbitjs.com/v0.15/guide/data-stores.html#Forking-stores

Also, there's an ember-orbit example project that illustrates the concept: https://github.com/cerebris/peeps-ember-orbit

@dgeb dgeb closed this as completed Jul 18, 2017
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

2 participants