Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nurfarazi/pubsub
Simple demonstration of pub-sub using just event and delegate
https://github.com/nurfarazi/pubsub
pubsub
Last synced: 2 days ago
JSON representation
Simple demonstration of pub-sub using just event and delegate
- Host: GitHub
- URL: https://github.com/nurfarazi/pubsub
- Owner: nurfarazi
- Created: 2023-04-25T11:30:32.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-05-05T12:24:00.000Z (over 1 year ago)
- Last Synced: 2024-11-09T13:28:24.989Z (about 2 months ago)
- Topics: pubsub
- Language: C#
- Homepage:
- Size: 3.67 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## simple demonstration of pub-sub using just event and delegate
You can use this example to understand the concept of event and delegate. It is a simple example of publisher and subscriber.
In this example, the publisher is a class called **`Publisher`** and the subscriber is a class called **`Subscriber`**. The publisher class
exposes an event called **`OnPublish`** and the subscriber class has a method called **`Subscribe`** that is subscribed to the publisher's
event.When the publisher class invokes its event, all the subscribed methods are invoked.
## How to run this example?
1. Download the source code
2. Open the solution file in Visual Studio
3. Compile the solution
4. Run the application
5. run the API project for the API
6. run the console project for the console applicationTry to understand the code and play with it. You can also add more subscribers to the publisher's event and see how it works.
## Attention
It is not good for production. you can use this example for learning and understanding the concept of pub sub.
I would prefer mediator pattern for production. you can find the mediator pattern example in other repository.