watcher
watcher copied to clipboard
Synchronous functions
Hey there!
Something that I am missing are sync functions.
watcher.writeSnapshotSync()
watcher.unsubscribeSync()
The reason is that when you use a separated thread to use this module you end up with a top level await functions that you have to make some gimmick to be able to use. When you have to exit your program you are not able to use some async functions. How I am going to write a snapshot without waiting to exit when you receive a process.exit() signal? At this point you need something synchronous because main thread needs to wait the command to finish. It can´t be async. The program is exiting, the main process sends a kill signal, the sub process will do things synchronously while main thread is waiting on process.kill command until everything is done. So to be able to use this module using async I will have to override the whole exit way of node, then send an ipc, and this ipc will use this async command that will emit a response to main thread, main thread then will be able to exit. This way of doing things does not work seamlessly with a dedicated thread for this module Thanks!