Closed arggh closed 8 years ago
Try to make a repro. The following works fine:
import { Template } from 'meteor/templating';
import './main.html';
ViewModel.signal({
mouse: {
mousePosition: {
target: document,
event: 'mousemove',
transform: function(event) {
return {
x: event.x,
y: event.y
}
},
throttle: 50
}
}
});
ViewModel.mixin({
test: {
signal: 'mouse'
}
})
Template.example.viewmodel({
mixin: 'test'
});
<body>
{{> example}}
</body>
<template name="example">
<p {{b "text: 'Mouse Position: ' + mousePosition.x + ',' + mousePosition.y"}}></p>
</template>
Here you go: https://github.com/arggh/signal-mixin-issue
Instructions are in client/main.js
, but it basically seems to boil down to using Mixin-scope.
Also, changing mixin: { myMixin: 'myMixin' }
to mixin: 'myMixin'
and adjusting the rest accordingly fixes it in my actual app as well.
This one will take a bit more work than I expected...
Pick up 5.0.0
Does ViewModel support (or are you planning on supporting?) using Signals from Mixins?
I have developed a situation, where I'm trying to capture an event from the
document
in a ViewModel Mixin.I had the same behaviour in multiple templates and it worked, but if I refactor the common parts into a Mixin, then the Signal stops working.