mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-13 08:52:25 +03:00
29 lines
915 B
JavaScript
29 lines
915 B
JavaScript
import getMetaInfo from '../shared/getMetaInfo'
|
|
import { isFunction } from '../shared/typeof'
|
|
import updateClientMetaInfo from './updateClientMetaInfo'
|
|
|
|
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
|
|
* action that resolves after the initial render takes place.
|
|
*
|
|
* Credit to [Sébastien Chopin](https://github.com/Atinux) for the suggestion
|
|
* to implement this method.
|
|
*
|
|
* @return {Object} - new meta info
|
|
*/
|
|
return function refresh() {
|
|
const metaInfo = getMetaInfo(options, this.$root)
|
|
|
|
const tags = updateClientMetaInfo(options, metaInfo)
|
|
|
|
// emit "event" with new info
|
|
if (tags && isFunction(metaInfo.changed)) {
|
|
metaInfo.changed.call(this, metaInfo, tags.addedTags, tags.removedTags)
|
|
}
|
|
|
|
return metaInfo
|
|
}
|
|
}
|