Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
December 27, 2022 07:16 am GMT

Easiest way to understand Pub/Sub System (kid friendly)

Imagine that you are in a library, and you want to borrow a book. You don't want to go to each shelf in the library and search for the book yourself, because that would take a lot of time and you might not even find the book. Instead, you decide to use the pubsub pattern to find the book.

Here's how you might use the pubsub pattern to find a book in the library:

  1. You are the publisher in this situation, because you are the one sending the "find book" message to everyone else. When you want to borrow a book, you go to the librarian and tell them the title of the book you are looking for.

  2. The library assistants are the subscribers in this situation, because they are the ones listening for the "find book" message. When a library assistant hears that someone is looking for a particular book, they go and search for the book on the shelves.

  3. The librarian is the message broker in this situation, because they are the ones who receive the "find book" message from you and send it to the appropriate subscribers. When you tell the librarian the title of the book you are looking for, they pass this message along to the library assistants, who start searching for the book.

This way, you don't have to go and search for the book yourself. You can just tell the librarian the title of the book you want, and the library assistants will do the work for you. This makes it easier to find the book you are looking for and borrow it from the library.


Original Link: https://dev.to/csituma/easiest-way-to-understand-pubsub-system-kid-friendly-3h5k

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To