2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-19 08:20:34 +03:00

refactor: minimize function calls / use of bind

This commit is contained in:
pimlie
2019-09-12 17:19:55 +02:00
parent ae98f65511
commit 0e49a9c43e
7 changed files with 94 additions and 56 deletions
+11 -13
View File
@@ -4,7 +4,7 @@ import getMetaInfo from '../shared/getMetaInfo'
import { isFunction } from '../utils/is-type'
import updateClientMetaInfo from './updateClientMetaInfo'
export default function _refresh (options = {}) {
export default function refresh (options = {}) {
/**
* When called, will update the current meta info with new meta info.
* Useful when updating meta info as the result of an asynchronous
@@ -15,20 +15,18 @@ export default function _refresh (options = {}) {
*
* @return {Object} - new meta info
*/
return function refresh () {
// collect & aggregate all metaInfo $options
const rawInfo = getComponentMetaInfo(options, this.$root)
// collect & aggregate all metaInfo $options
const rawInfo = getComponentMetaInfo(options, this.$root)
const metaInfo = getMetaInfo(options, rawInfo, clientSequences, this.$root)
const metaInfo = getMetaInfo(options, rawInfo, clientSequences, this.$root)
const appId = this.$root._vueMeta.appId
const tags = updateClientMetaInfo(appId, options, metaInfo)
const appId = this.$root._vueMeta.appId
const tags = updateClientMetaInfo(appId, options, metaInfo)
// emit "event" with new info
if (tags && isFunction(metaInfo.changed)) {
metaInfo.changed(metaInfo, tags.addedTags, tags.removedTags)
}
return { vm: this, metaInfo, tags }
// emit "event" with new info
if (tags && isFunction(metaInfo.changed)) {
metaInfo.changed(metaInfo, tags.addedTags, tags.removedTags)
}
return { vm: this, metaInfo, tags }
}