turbowatch
turbowatch copied to clipboard
Replace initialRun with onStart
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
onStartfails, should it be restarted? - If
onStartfails, should Turbowatch exit with an error? - Should
onChangebe blocked untilonStartcompletes? - How would it work with
persistenttriggers?, i.e. Would we only triggeronStartand never triggeronChange?
FYI @hyldmo