Skip to content

Add utility to allow type-safe yields #5

Description

@AlCalzone

Probably something like this:

function* waitFor<T>(yieldExpr: () => Promise<T>): Generator<Promise<T>, T, T> {
    const unwrapped = yield yieldExpr;
    return unwrapped;
}
function* task() {
    const x = yield* waitFor(() => Promise.resolve(5));
    const y = yield* waitFor(() => Promise.resolve('hello'));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions