Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget-status always showing "a few seconds" #82

Open
L-Francois opened this issue Apr 5, 2019 · 2 comments
Open

Widget-status always showing "a few seconds" #82

L-Francois opened this issue Apr 5, 2019 · 2 comments

Comments

@L-Francois
Copy link

Hello,

If my widget is connected to a rest datasource with a call every x minutes, the when variable is always showing "a few seconds". It seems that this code is only evaluated at the first load of the page and not triggered anymore:

computed: {
  when: _updated => {
    return moment(_updated).fromNow(true)
  }

Thanks,
François

@L-Francois
Copy link
Author

Hello,

I adapted the code to refresh it differently every 10 seconds, there are maybe better ways, discovering nodejs & co:

'use strict'
import moment from 'moment'

export default {
onstate () {
var self = this
setInterval(function() {
self.set({ when: self.refresh() });
}, 10000);
},
data () {
return {
description: '-',
components: {},
_lastupdated: moment(),
when: '-'
}
},
methods: {
update ({ data, meta }) {
this._lastupdated = meta.updated
this.when = moment(this._lastupdated).fromNow()
this.set(data)
},
refresh () {
return moment(this._lastupdated).fromNow()
}
}
}

Regards,
François

@antony
Copy link
Collaborator

antony commented May 15, 2019

Heya - sorry I've not had a huge amount of time to work on Vudash recently!

The goal with _updated is that it is a property always sent by the core Vudash dashboard, and doesn't need to be sent by individual widgets. However, it's possible that there is an issue preventing this from working.

When my schedule frees up a bit I'll have a look into this and see if I can determine why there may be an issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants