-
Notifications
You must be signed in to change notification settings - Fork 42
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
LiveQuery lifetimes #311
Comments
@ef4 I definitely see where you're coming from and would be glad to integrate a similar solution into ember-orbit. I'd prefer to not hard-link the We should consider incorporating the ability to create a dependent relationship in // app/components/my-component.js
import { liveQuery } from '../lib/query';
export default class extends Component {
@service store;
observations = this.store.cache.liveQuery((qb) =>
qb.findRecords('observation').sort('-time')
).associateParent(this);
} |
My plan is to wait for |
The problem I see with suggested utilities is that there no way with them to bind live query to some of component tracked properties. Another advantage of |
You can implement this with tracked property support already, without any private API. Here's a demo that does that for a Now that the destroyables API is shipping in the current Ember release (and polyfilled), you could combine destroyable plus this pattern to do all of this in an addon. |
I see that LiveQuery uses the ember-destroyable-polyfill, and that all queries get destroyed when the cache itself gets destroyed.
But it seems likely that many live queries have a lifetime shorter than that, like being associated with a component. In my own experiments, I have a utility like this:
That I use like this:
This ensures that the live query is destroyed whenever its parent component is destroyed.
Is there a better built-in solution? Should something like this utility be added to ember-orbit?
The text was updated successfully, but these errors were encountered: