I have a service called screen-size which has a property called width. This property is the value of the window width and will update on a resize event.
This works fine. In a component, I have a computed property that I want to update when this value changes like so...
nameStyle: computed('screenSizeService.width', function()
{
console.log('in computed');
return this.getFontSize(2.5, 2, null, null, this.$())
}),
This is only running once at the beginning unless I do this...
nameStyle: computed('screenSizeService.width', function()
{
this.get('screenSizeService.width');
console.log('in computed');
return this.getFontSize(2.5, 2, null, null, this.$())
}),
Then it runs correctly. The value of nameStyle has no direct relation to the screen width, but the container width which changes when the screen width changes.
This is why i read from the screen width.
Why would I need to get the value in order for it to work? Why wouldnt it just computed from when it changes and run that function?
Aucun commentaire:
Enregistrer un commentaire