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

Schedule runnables to run once #10

Open
krispya opened this issue Jun 3, 2024 · 1 comment
Open

Schedule runnables to run once #10

krispya opened this issue Jun 3, 2024 · 1 comment
Assignees

Comments

@krispya
Copy link
Member

krispya commented Jun 3, 2024

An example is an init function. A work around is to early out after the first run, but it would be even better if it were just removed from the sort entirely.

I figure the API can look like this, though I don't know the best way it could be implemented.

test('scheduling runnables once', () => {
    const schedule = create();

    add(schedule, aFn, id('A'), once());
    add(schedule, bFn, after('A'), id('B'));
    add(schedule, cFn, after('B'), id('C'));

    run(schedule, {});

    expect(order).toEqual(['A', 'B', 'C']);

    order = [];
    run(schedule, {});

    expect(order).toEqual(['B', 'C']);
})
@akdjr akdjr self-assigned this Jun 19, 2024
@akdjr
Copy link
Collaborator

akdjr commented Jun 19, 2024

Depends on #15 and a bit of #17 in order to not wreck references and allow maximum flexibility with the once modifier.

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

No branches or pull requests

2 participants