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

Use orbit LiveQuery #269

Closed
wants to merge 4 commits into from
Closed

Use orbit LiveQuery #269

wants to merge 4 commits into from

Conversation

tchak
Copy link
Member

@tchak tchak commented Jun 21, 2020

This implementation relies on a helper which is meant to be used through emberjs/rfcs#626

I also implemented a @use api borrowing from ember-usable.

It looks like this:

import Component from '@glimmer/component';
import { use, useLiveQuery } from 'ember-orbit';

export default class extends Component {
   @use data = useLiveQuery((q) => q.findRecords('planet'));
}

I know that https://github.com/LevelbossMike/ember-statecharts shipped something similar. I really don't know if it is a bad idea/too early for orbit to ship something like this. But at least it shows the direction where we might want to go.

cc @NullVoxPopuli @LevelbossMike

@tchak tchak force-pushed the use-live-query branch 5 times, most recently from 0d80a0e to 15bea30 Compare June 21, 2020 18:05
export default class extends Component<Args> {
@use data = useLiveQuery((q) =>
this.args.id
? q.findRecord({ type: 'planet', id: this.args.id })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this re-run if the args change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will not. After some thoughts, I think we should wait for invokeHelper/use apis to settle.

@tchak
Copy link
Member Author

tchak commented Jul 4, 2020

Closing in favour of #276

@tchak tchak closed this Jul 4, 2020
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

Successfully merging this pull request may close these issues.

2 participants