-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
RFC: re-envision Encapsulated Tasks #466
Comments
Playing around with the syntax a bit; the above could also be written as class MyComponent extends Component {
@tracked componentCounter = 0;
static MyTaskInstance = class extends TaskInstance<MyComponent> {
@tracked counter = 0;
async perform(inc: number) {
while(true) {
await timeout(500);
this.counter += inc;
this.context.componentCounter += inc;
}
}
}
myTask = task({ drop:true }, MyComponent.MyTaskInstance);
} or even class MyComponent extends Component {
@tracked componentCounter = 0;
myTask = task(
{ drop: true },
class extends TaskInstance<MyComponent> {
@tracked counter = 0;
async perform(inc: number) {
while (true) {
await timeout(500);
this.counter += inc;
this.context.componentCounter += inc;
}
}
}
);
} |
I like the proposed API a lot because it removes the need to do a bunch of the meta-programming-type stuff we do now to mixin bits of the
|
Placeholder RFC; TODO: add more details.
This is a design for a future API for encapsulated tasks that should be TS-friendly and support all of today's use cases for encapsulated tasks:
task()
factory fn will accept the subclass as an argthis.context
<MyComponent>
type argThe text was updated successfully, but these errors were encountered: