PubSub

Build on the fundamentals of PubSub by selecting the topic in this lesson.

Selecting a topic name

A carefully selected topic name is vital for the scalability and behavior of an application. For instance, a public Channel providing inventory updates to an e-commerce storefront could be implemented in a variety of ways:

  • inventory: This topic does not delineate between different SKUsStock Keeping Units.
  • inventory:*: This topic delineates between different item SKUsStock Keeping Units with a wildcard.

If an overly broad topic is selected, such as inventory, then an inventory change to an SKU is broadcast to every connected client, even if they are not viewing the item. A narrower topic such as inventory:* would lead to more connected topics (one per viewed item) but means that outgoing data could be held back from clients that aren’t viewing a particular SKU.

In this example, we would select a ...