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.

<strong>Vue</strong>x<br />

<strong>Vue</strong>x (usually pronounced veweks) is the official <strong>Vue</strong>.<strong>js</strong> implementation of the<br />

Flux architecture. By enforcing the principles described previously, <strong>Vue</strong>x keeps<br />

your application data in a transparent <strong>and</strong> predictable state even when that data is<br />

being shared across many components.<br />

<strong>Vue</strong>x includes a store with state <strong>and</strong> mutator methods, <strong>and</strong> will reactively update<br />

any components that are reading data from the store. It also allows for h<strong>and</strong>y<br />

development features like hot module reloading (updating modules in a running<br />

application) <strong>and</strong> time-travel debugging (stepping back through mutations to trace<br />

bugs).<br />

In this chapter, we will add a save feature to our <strong>Vue</strong>bnb listings so that a user<br />

can keep track of the listings that they like best. Unlike other data in our app so<br />

far, the saved state must persist across pages; for example, when a user changes<br />

from one page to another, the app must remember which items the user has<br />

already saved. We will use <strong>Vue</strong>x to achieve this:<br />

Figure 8.4. Saved state is available to all page components

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

Saved successfully!

Ooh no, something went wrong!