Skip to content

Implement Observer (Listener) Pattern for Online Marketplace Events Using NodeJS#70

Open
EpitomeZied wants to merge 1 commit intomahyoussef:mainfrom
EpitomeZied:main
Open

Implement Observer (Listener) Pattern for Online Marketplace Events Using NodeJS#70
EpitomeZied wants to merge 1 commit intomahyoussef:mainfrom
EpitomeZied:main

Conversation

@EpitomeZied
Copy link
Copy Markdown

This pull request introduces a new implementation of the Observer (Listener) design pattern for an online marketplace scenario. It adds a set of classes to model publishers, subscribers, events, and domain entities, enabling decoupled notifications for new products, offers, and job openings. Additionally, it adds a runnable example and documentation to demonstrate the new pattern.

Key changes include:

Observer Pattern Implementation:

Added the OnlineMarketplace publisher, which manages subscriptions and notifies listeners for different event types.
Added the Subscriber base class and concrete subscribers: Customer, JobFinder, and ShippingCompany, each with custom notification behavior.
Added EventType to define supported notification topics (NEW_PRODUCT, NEW_OFFER, JOB_OPENING).
Added Product and Offer domain entities used in published events.

Example and Documentation Updates:

Added main.js to demonstrate subscribing observers and triggering events.
Added Pattern.md with a Mermaid class diagram documenting the design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant