Skip to content

Latest commit

 

History

History
35 lines (21 loc) · 1.69 KB

README.md

File metadata and controls

35 lines (21 loc) · 1.69 KB

fs-event-action

Run a cancellable asynchronous action triggered via file system (FS) events.

  • Utilizes chokidar to monitor FS events in a directory.
  • Upon any FS event, a "Cancellable" action is initiated. The cancellable action is crafted using c-promise2.
    • Explore CodeSandbox examples in the c-promise2 repository to understand its usage.
    • Refer to this video for insights into how generator/yield is employed to write async/await logic.
      • Generator functions are employed by c-promise2 to create cancellable asynchronous routines.
    • A custom ShellProcess class is available in src/utils/ShellProcess.ts for executing cancellable terminal commands.

Usage

  • Run development script: yarn dev
  • Build script: yarn build
    • Outputs to /dist

Create Your Own Event Action

  • Refer to src/event-action.example.ts for an example demonstrating how to create cancellable logic.
  • Subsequent triggers of the Event Action will cancel the previously triggered Event Action if it is still running.

Demo

Kapture.2024-01-12.at.09.58.09.mp4

Further Development

  • The current examples may have incomplete TypeScript type definitions due to the absence of type definitions for the c-promise2 library.