turbowatch icon indicating copy to clipboard operation
turbowatch copied to clipboard

Replace initialRun with onStart

Open gajus opened this issue 2 years ago • 1 comments
trafficstars

As reported in https://github.com/gajus/turbowatch/issues/41, the initialRun API might be a bit confusing for first-time users because it triggers onChange with an empty array. A simpler API would be to simply add onStart hook. However, there are trade-offs.

At the moment, initialRun triggers onChange, which if it fails, user could just re-run it the next time a change is detected. Adding onStart means that we need to think of how to handle onStart failing.

Open questions:

  • If onStart fails, should it be restarted?
  • If onStart fails, should Turbowatch exit with an error?
  • Should onChange be blocked until onStart completes?
  • How would it work with persistent triggers?, i.e. Would we only trigger onStart and never trigger onChange?

gajus avatar Apr 10 '23 17:04 gajus

FYI @hyldmo

gajus avatar Apr 10 '23 17:04 gajus