I have a child that gets props from parent and ,on button clicked, emits to parent via event bus.
On emit i launch method that fetches data via swagger-client.
The aim is to recreate array of activities after child click.
The activities items have date property that is converted to momentjs method fromNow. {{myFromNow(item.date)}}
The problem is that when i fetch fresh list (and set it to vm.activities), the topmost item's date gets refreshed for brief second before it is substituted via new item on the list. I flickers new date and its visible with naked eye.
methods:{
getActivity(){
let vm = this
this.$swagger.Activity.Activity_activityAll(
{
filter: JSON.stringify({
order: 'Date DESC',
include: [{
relation: 'person',
scope: {
order: 'DateCreated ASC'
}
}
]
})
}
)
.then(function (resp) {
vm.$set(vm, 'activity', resp.body['activity'])
})
}
}
and the listener is on mounted
mounted () {
let vm = this
this.$eventBus.$on('childAction', () => {
vm.getActivity()
})
},
If i run debugger it clearly shows that fromNow is updated after
vm.$set(vm, 'activity', resp.body['activity'])
and list is updated only after end of method:
Do you have any idea what could cause it?
activity
in computed property and iterate over that. – Mike