Commit 8255a01b authored by Evan You's avatar Evan You

fetchData -> asyncData

parent 0253ebcc
...@@ -5,9 +5,9 @@ import { createApp } from './app' ...@@ -5,9 +5,9 @@ import { createApp } from './app'
// a global mixin to invoke fetchData on the client // a global mixin to invoke fetchData on the client
Vue.mixin({ Vue.mixin({
beforeMount () { beforeMount () {
const { fetchData } = this.$options const { asyncData } = this.$options
if (fetchData) { if (asyncData) {
this.dataPromise = fetchData( this.dataPromise = asyncData(
this.$store, this.$store,
this.$route this.$route
) )
......
...@@ -27,7 +27,7 @@ export default context => { ...@@ -27,7 +27,7 @@ export default context => {
// which is resolved when the action is complete and store state has been // which is resolved when the action is complete and store state has been
// updated. // updated.
Promise.all(matchedComponents.map(component => { Promise.all(matchedComponents.map(component => {
return component.fetchData && component.fetchData( return component.asyncData && component.asyncData(
store, store,
router.currentRoute, router.currentRoute,
context context
......
...@@ -10,7 +10,7 @@ export default function createListView (type) { ...@@ -10,7 +10,7 @@ export default function createListView (type) {
return { return {
name: `${type}-stories-view`, name: `${type}-stories-view`,
fetchData (store, route, context) { asyncData (store, route, context) {
return store.dispatch('FETCH_LIST_DATA', { type }).then(() => { return store.dispatch('FETCH_LIST_DATA', { type }).then(() => {
setTitle(camelize(type), context) setTitle(camelize(type), context)
}) })
......
...@@ -46,7 +46,7 @@ export default { ...@@ -46,7 +46,7 @@ export default {
} }
}, },
fetchData (store, { params: { id }}, context) { asyncData (store, { params: { id }}, context) {
return store.dispatch('FETCH_ITEMS', { ids: [id] }).then(() => { return store.dispatch('FETCH_ITEMS', { ids: [id] }).then(() => {
const item = store.state.items[id] const item = store.state.items[id]
setTitle(item.title, context) setTitle(item.title, context)
......
...@@ -30,7 +30,7 @@ export default { ...@@ -30,7 +30,7 @@ export default {
} }
}, },
fetchData (store, { params: { id }}, context) { asyncData (store, { params: { id }}, context) {
return store.dispatch('FETCH_USER', { id }).then(() => { return store.dispatch('FETCH_USER', { id }).then(() => {
const user = store.state.users[id] const user = store.state.users[id]
setTitle(user.id, context) setTitle(user.id, context)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment