Skip to content

Better system chaining / piping #11571

Closed as not planned
Closed as not planned
@Adamkob12

Description

@Adamkob12

What problem does this solve or what need does it fill?

There are many different methods to control the execution flow of a system set. I think many of them could be unified into an easy and intuitive API. For example, "piping" and "chaining" systems is essentially the same thing: you could look at "chaining" as piping () . Ideally, these two concepts should be merged into a nice and consistent API.

What solution would you like?

I think we can achieve a really nice looking API by utilizing the Shr (or Shl) traits.
For example:

Simple chaining

// Before:
(sys1, sys2, sys3).chain()

// After:
sys1 >> sys2 >> sys3

Simple piping

// Before:
sys1.pipe(sys2).pipe(sys3)

// After:
sys1 >> sys2 >> sys3

Complex chaining + piping

// Before:
(((sys1, sys2, sys3).chain(), sys4, sys5.pipe(sys6)), sys7).chain()

// After:
(sys1 >> sys2 >> sys3, sys4, sys5 >> sys6) >> sys7

What alternative(s) have you considered?

Keep the API as is

Additional context

  • We can also use declarative macros. That would offer more flexibility, but it will be harder to implement and maintain (and it's not guaranteed to make the API feel better)
  • This could open the gate for "1-N piping" (piping the output of a system into many systems)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useX-ControversialThere is active debate or serious implications around merging this PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions