one with naviga4on is always visible => it'll be our skeleton • right one will be changing depending on what we want to see => we will need a router • Empty state is our default, because we don't have anything to show now
by any exis2ng API, so I can do whatever I want now • It will be a list of recent calls => array • we don't have much choice how to render list => v-for="call in calls" to iterate
iden+fier for links, so I've added id to the calls.json • let's use standard <router-link> which transforms into standard <a> (so "Open in a new panel" works in your browser) <!-- components/call.vue --> <div class="call"> <!-- from this --> <router-link class="call" :to="{ name: 'Call', params: { id: call.id } }"> <!-- ... --> </router-link>
of calls to Vuex // store.js import Vue from 'vue'; import Vuex from 'vuex'; import calls from './calls.json'; Vue.use(Vuex); // Initialize export default new Vuex.Store({ state: { calls, }, });
import Vue from 'vue'; import App from './App'; import store from './store'; import router from './router'; new Vue({ el: '#app', router, store, // Add Vuex store to the app template: '<App/>', components: { App }, });
orders to the store. Like: "do this ac6on" or "do this ac6on, with this value" Components are just saying eg.: • User did something, go fetch new data • User did something, change your data
serializable Object of current state • ge&ers: read-only helpers that can transform value (eg. filter an array). They get their data from read-only state. Example coming up. • muta*ons: only way to write to the state. Simple synchronous funcFons that can modify the state. • ac*ons: larger, possibly asynchronous or chained funcFons, that can start a mutaFon. Imagine AJAX call, that on success passes data to the mutaFon to do the state write.
data to the right side. Why ge#er? Because its value is changing depending on state of the applica6on (different routes will want to see different data on the right)
could do it manually, by crea:ng muta:ons, but there is an official helper vuex- router-sync. This adds current route Object to Vuex state. // main.js import Vue from 'vue'; import { sync } from 'vuex-router-sync'; // import the package import App from './App'; import store from './store'; import router from './router'; sync(store, router); // sync Store with Router, done new Vue({ el: '#app', router, store, template: '<App/>', components: { App }, });