25.06.2018 Views

Full-Stack Vue.js 2 and Laravel 5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Flux application architecture<br />

Imagine you've developed a multi-user chat app. The interface has a user list,<br />

private chat windows, an inbox with chat history <strong>and</strong> a notification bar to inform<br />

users of unread messages.<br />

Millions of users are chatting through your app on a daily basis. However, there<br />

are complaints about an annoying problem: the notification bar of the app will<br />

occasionally give false notifications; that is, a user will be notified of a new<br />

unread message, but when they check to see what it is, it's just a message they've<br />

already seen.<br />

What I've described is a real scenario that Facebook developers had with their<br />

chat system a few years ago. The process of solving this inspired their<br />

developers to create an application architecture they named Flux. Flux forms the<br />

basis of <strong>Vue</strong>x, Redux <strong>and</strong> other similar libraries.<br />

Facebook developers struggled with this zombie notification bug for some time.<br />

They eventually realized that its persistent nature was more than a simple bug; it<br />

pointed to an underlying flaw in the architecture of the app.<br />

The flaw is most easily understood in the abstract: when you have multiple<br />

components in an application that share data, the complexity of their<br />

interconnections will increase to a point where the state of the data is no longer<br />

predictable or underst<strong>and</strong>able. When bugs like the one described inevitably arise,<br />

the complexity of the app data makes them near impossible to resolve:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!