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?
As reported in https://github.com/gajus/turbowatch/issues/41, the
initialRun
API might be a bit confusing for first-time users because it triggersonChange
with an empty array. A simpler API would be to simply addonStart
hook. However, there are trade-offs.At the moment,
initialRun
triggersonChange
, which if it fails, user could just re-run it the next time a change is detected. AddingonStart
means that we need to think of how to handleonStart
failing.Open questions:
onStart
fails, should it be restarted?onStart
fails, should Turbowatch exit with an error?onChange
be blocked untilonStart
completes?persistent
triggers?, i.e. Would we only triggeronStart
and never triggeronChange
?