-
-
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
Add waitFor
support to async arrow function API
#531
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -796,6 +796,16 @@ type OptionTypeFor<T, F> = F extends (...args: infer Args) => T | |
type TaskOptions = OptionsFor<TaskProperty<unknown, unknown[]>>; | ||
type TaskGroupOptions = OptionsFor<TaskGroupProperty<unknown>>; | ||
|
||
type AsyncArrowFunctionTaskOptions< | ||
HostObject, | ||
T, | ||
Args extends any[] | ||
> = TaskOptions & { | ||
waitFor?: ( | ||
fn: AsyncArrowTaskFunction<HostObject, T, Args> | ||
) => AsyncArrowTaskFunction<HostObject, T, Args>; | ||
}; | ||
|
||
Comment on lines
+799
to
+808
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might not be needed to be special-cased if moved to a |
||
type MethodOrPropertyDecoratorWithParams<Params extends unknown[]> = | ||
MethodDecorator & | ||
PropertyDecorator & | ||
|
@@ -919,7 +929,7 @@ export function task< | |
|
||
export function task< | ||
HostObject, | ||
O extends TaskOptions, | ||
O extends AsyncArrowFunctionTaskOptions<HostObject, any, any[]>, | ||
T extends AsyncArrowTaskFunction<HostObject, any, any[]> | ||
>( | ||
hostObject: HostObject, | ||
|
@@ -929,7 +939,7 @@ export function task< | |
|
||
export function task< | ||
HostObject, | ||
O extends TaskOptions, | ||
O extends AsyncArrowFunctionTaskOptions<HostObject, any, any[]>, | ||
T extends AsyncArrowTaskFunction<HostObject, any, any[]> | ||
>(baseOptions: O, asyncArrowTaskFn: T): TaskForAsyncTaskFunction<HostObject, T>; | ||
|
||
|
@@ -981,7 +991,7 @@ export function dropTask< | |
>(asyncArrowTaskFn: T): TaskForAsyncTaskFunction<HostObject, T>; | ||
export function dropTask< | ||
HostObject, | ||
O extends TaskOptions, | ||
O extends AsyncArrowFunctionTaskOptions<HostObject, any, any[]>, | ||
T extends AsyncArrowTaskFunction<HostObject, any, any[]> | ||
>(baseOptions: O, asyncArrowTaskFn: T): TaskForAsyncTaskFunction<HostObject, T>; | ||
|
||
|
@@ -1030,7 +1040,7 @@ export function enqueueTask< | |
|
||
export function enqueueTask< | ||
HostObject, | ||
O extends TaskOptions, | ||
O extends AsyncArrowFunctionTaskOptions<HostObject, any, any[]>, | ||
T extends AsyncArrowTaskFunction<HostObject, any, any[]> | ||
>(baseOptions: O, asyncArrowTaskFn: T): TaskForAsyncTaskFunction<HostObject, T>; | ||
|
||
|
@@ -1079,7 +1089,7 @@ export function keepLatestTask< | |
|
||
export function keepLatestTask< | ||
HostObject, | ||
O extends TaskOptions, | ||
O extends AsyncArrowFunctionTaskOptions<HostObject, any, any[]>, | ||
T extends AsyncArrowTaskFunction<HostObject, any, any[]> | ||
>(baseOptions: O, asyncArrowTaskFn: T): TaskForAsyncTaskFunction<HostObject, T>; | ||
|
||
|
@@ -1128,7 +1138,7 @@ export function restartableTask< | |
|
||
export function restartableTask< | ||
HostObject, | ||
O extends TaskOptions, | ||
O extends AsyncArrowFunctionTaskOptions<HostObject, any, any[]>, | ||
T extends AsyncArrowTaskFunction<HostObject, any, any[]> | ||
>(baseOptions: O, asyncArrowTaskFn: T): TaskForAsyncTaskFunction<HostObject, T>; | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -58,6 +58,7 @@ import { | |||||
} from 'ember-concurrency'; | ||||||
import { expectTypeOf as expect } from 'expect-type'; | ||||||
import { taskFor } from 'ember-concurrency-ts'; | ||||||
import { waitFor } from '@ember/test-waiters'; | ||||||
|
||||||
declare type TestCallback = () => void | Promise<void>; | ||||||
declare function module(description: string, callback: TestCallback): void; | ||||||
|
@@ -3128,6 +3129,7 @@ module('integration tests', () => { | |||||
debug = task(this, { debug: true }, async () => {}); | ||||||
onState = task(this, { onState: () => {} }, async () => {}); | ||||||
onStateNull = task(this, { onState: null }, async () => {}); | ||||||
waitFor = task({ waitFor }, async () => {}); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is missing the
Suggested change
|
||||||
|
||||||
// Note: these options work even when strictFunctionTypes is enabled, but | ||||||
// turning it on in this repo breaks other things in addon/index.d.ts | ||||||
|
@@ -3237,6 +3239,7 @@ module('integration tests', () => { | |||||
debug = task({ debug: true }, async () => {}); | ||||||
onState = task({ onState: () => {} }, async () => {}); | ||||||
onStateNull = task({ onState: null }, async () => {}); | ||||||
waitFor = task({ waitFor }, async () => {}); | ||||||
|
||||||
// Note: these options work even when strictFunctionTypes is enabled, but | ||||||
// turning it on in this repo breaks other things in addon/index.d.ts | ||||||
|
@@ -3409,6 +3412,7 @@ module('integration tests', () => { | |||||
debug = task({ debug: true }, async () => {}); | ||||||
onState = task({ onState: () => {} }, async () => {}); | ||||||
onStateNull = task({ onState: null }, async () => {}); | ||||||
waitFor = task({ waitFor }, async () => {}); | ||||||
|
||||||
// Note: these options work even when strictFunctionTypes is enabled, but | ||||||
// turning it on in this repo breaks other things in addon/index.d.ts | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this probably should be moved into a modifier (a la #513), so that it works regardless of whether a task is running through the AyncArrowRuntime or not