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 ...

Get Vue.js 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.