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

[FEAT] Run conditions #57

Open
JaimeGensler opened this issue Nov 23, 2023 · 0 comments
Open

[FEAT] Run conditions #57

JaimeGensler opened this issue Nov 23, 2023 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@JaimeGensler
Copy link
Owner

JaimeGensler commented Nov 23, 2023

Describe the problem this feature solves

A mechanism to specify whether a system or group of systems should run at all would be nice. You can kind of do this with an early return, but you may have to access data you otherwise don't care about to do this, which isn't great. Also maybe better optimization potential if they exist external to systems.

Describe the solution you'd like to see

For the API, a run condition is a function that returns a boolean - true if the system(s) should run, false if they should not. It will be supplied as the third argument for World.p.addSystems (Schedule addSystem unknown).
The function can either be a system, or a function that accepts the world instance. If the getSystemParameters property exists on the function, it will be treated as a system and its arguments will be parsed. If not, it will be supplied the world.

Example usage:

type RunCondition = (...args: any[]) => boolean;
class World {
  addSystems(
    scheduleType: ScheduleType,
    systems: System | System[],
    condition: RunCondition
  ): this
}

// In use
const world = await new World()
  .addSystems(Schedule, mySystem, world => world.getResource(SomeResource).someProperty)
  .prepare()

Open Questions

  1. When should this be evaluated?
    a. Every runSchedule() call
    b. When prepare() is called
    c. A third API, included in prepare() but called separately?
@JaimeGensler JaimeGensler added the enhancement New feature or request label Nov 23, 2023
@JaimeGensler JaimeGensler added the good first issue Good for newcomers label Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: No status
Development

No branches or pull requests

1 participant