You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Message is an enum-like singleton object that stores string values for event messages passed through the MessageBus. Creating a singleton like this gives us a number of benefits.
Typos in event message string values are eliminated. Without this Message object, a typo in a string will not break the MessageBus; the listener will just fail to fire. Keeping the string value locked away in a Message object helps prevent this.
String literals aren't generally tokenized by minifiers. Creating the Message object allows references to these strings to be tokenized, allowing better file minification.
It provides a catalogue of all events. Being forced to catalogue our new event in the Message object will allow us the opportunity to be reminded of events we may have created in the past that serve the same purpose, promoting reuse.