Skip to content

Use orbit LiveQuery#269

Closed
tchak wants to merge 4 commits intoorbitjs:masterfrom
tchak:use-live-query
Closed

Use orbit LiveQuery#269
tchak wants to merge 4 commits intoorbitjs:masterfrom
tchak:use-live-query

Conversation

@tchak
Copy link
Contributor

@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 })
Copy link
Contributor

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
Contributor 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
Contributor 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