When a scratchfile is created CAN should start to watch it¶
To manage this, an event handler pattern will be used. Commands will be given access to emitters for specific events, and the entry file for CAN will set up handlers for the events.
In this case, two events will be needed: SCRATCHFILE_CREATED
and SCRATCHFILE_UPDATED
.
The scratch command will trigger the former event, which will have a handler ready to set up a file watcher. When the file watcher detects a change, it will trigger the SCRATCHFILE_UPDATED
event.
When the SCRATCHFILE_UPDATED
event is detected, CAN will inform the user.
Backlinks¶
- CAN should fire a SCRATCHFILE_UPDATED event when the scratchfile is updated
- When a scratchfile is created CAN should start to watch it. When CAN detects a change in the scratchfile, a SCRATCHFILE_UPDATED event should be emitted.
- CAN should begin watching an existing scratchfile on startup
- CAN fires a SCRATCHFILE_CREATED event. This is a similar but distinct event whic may repeat in multiple contexts if CAN allows multiple scratchfiles in the future - SCRATCHFILE_FOUND. CAN should fire a SCRATCHFILE_FOUND event when an existing scratchfile is found. CAN's watch-scratchfile handler should listen to the SCRATCHFILE_FOUND event.