How it works...
I think it's important to note the names of the mutations; they are called pushMessage and removeMessage, but what they really do in this application is show the message in a stack on the screen and (fictionally) broadcast messages to users. Would it be better to call them showMessage, or broadcastMessage and hideMessage? No, that's because there has to be a clear separation of intent between the mutation itself and the particular effects of that mutation. The problem becomes clear when, for example, we decide to give users the ability to ignore these notifications or we introduce a delay before actually broadcasting the notifications. Then we will have a showMessage mutation that does not actually show a message.
The computed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access