dillonkearns / elm-pages

Hybrid Elm framework with full-stack and static routes.
https://elm-pages.com
BSD 3-Clause "New" or "Revised" License
658 stars 97 forks source link

Feature request: `BackendTask.race` #459

Closed miniBill closed 7 months ago

miniBill commented 8 months ago

race : BackendTask error a -> BackendTask error a -> BackendTask error a would run two tasks in parallel and return when the first one returns.

This is useful for, for example, timeouts, or watching multiple files/sockets.

dillonkearns commented 7 months ago

Timing stuff is a little bit weird with BackendTask because it executes things on one level before moving on to the next, so I'd be somewhat reluctant to add that because it might mislead people. There isn't super fine-grained control over timing because of that, and having race might make it appear that there is more granular control over those things. Also I think that cancelling a backend task gets tricky because it would need a pretty different architecture, and people might also expect race to cancel the "loser" in the race. I'll close this issue for those reasons, but happy to discuss more if you have other thoughts.