This repository demonstrates my implementation of the Pub-Sub design pattern as part of the assignment for Taobin.
The implementation consists of the following components:
machine.ts: Defines the machine entity and its stock management.event.ts: Represents events that can be published and subscribed to.subscribe.ts: Handles subscriber behavior for different event types.PublishSubscribeService.ts: Implements the pub-sub mechanism to manage event publication and subscription.main.ts: Contains the main logic to demonstrate and test the system's functionality.
Additionally, the idea.ts and app.ts files are prototypes and not part of the main execution process.
- Install Node.js and TypeScript.
- Clone this repository to your local machine.
- Open a terminal in the repository's root directory.
- Use the following commands:
- Build: Compile TypeScript files to JavaScript.
make build
- Run: Execute the program.
make run
- Clean: Remove compiled JavaScript files.
make clean
- Help: Display available commands.
make help
- Build: Compile TypeScript files to JavaScript.
- Compile the TypeScript code:
tsc main.ts