minart icon indicating copy to clipboard operation
minart copied to clipboard

Experiment with subsystems as capabilities

Open JD557 opened this issue 4 months ago • 0 comments

The AppLoop logic is currently a bit wonky, especially the *AppLoop variants, with a (CanvasSubsystem with AudioPlayerSubsystem) cake.

With Scala 3, I think it should be possible to redefine it as something like:

  def statefulAppLoop[State](
      renderFrame: State => (Canvas, AudioPlayer) ?=> State,
      terminateWhen: State => Boolean = (_: State) => false
  ): AppLoop.Definition[State, (Canvas.Settings, AudioPlayer.Settings), LowLevelAllSubsystems] =
    statefulLoop[State, (Canvas.Settings, AudioPlayer.Settings), LowLevelAllSubsystems](
      renderFrame,
      terminateWhen
    )

I think I still need to think a bit about the (Canvas.Settings, AudioPlayer.Settings) and LowLevelAllSubsystems. It's not as easy as it looks due to the default backends.

Some inspiration: https://nrinaudo.github.io/articles/capabilities.html

JD557 avatar Sep 10 '25 21:09 JD557