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

Query array eager register/append #233

Open
ampatspell opened this issue Mar 18, 2021 · 1 comment
Open

Query array eager register/append #233

ampatspell opened this issue Mar 18, 2021 · 1 comment

Comments

@ampatspell
Copy link
Owner

let doc = store.doc(...).new({ ... });
let cancel = this.query.append(doc);
let model = this.models.find(model => model.doc === doc);
try {
  await doc.save();
} catch(err) {
  cancel();
}
  • Immediately appends doc (query array needs 2 content arrays -- live data and appended)
  • register returns fn which removes doc from appended (if save fails or whatnot)
  • appended docs work the same way as registered docs.
  • if onSnapshot returns the same doc, it is removed from appended and moved to live data array
@ampatspell
Copy link
Owner Author

In addition to that, doc.delete() should also have support for this.

let model = this.models.find(model => model.id === 'foof');
let cancel = this.query.remove(doc);
// this.models.includes(model) // → false

try {
  await model.doc.delete();
} catch(err) {
  cancel();
}

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

1 participant