We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi, i try functions onCreated, autorun but not working
ViewModel.share({ clock: { initialTime: new Date(), onCreated() { this.initialTime( new Date() ); console.log('onCreated:' , this.initialTime()) }, autorun(){ console.log('autorun:' , this.initialTime()) } } }); Template.example1.viewmodel({ share: 'clock' }); Template.example2.viewmodel({ share: 'clock' });
The text was updated successfully, but these errors were encountered:
This is indeed not working at all. If you try to do this:
Template.example2.viewmodel({ share: 'clock' onCreated: function() { console.log(this.clock); } });
it will throw an error saying _this.clock is not a function
Sorry, something went wrong.
@satyavh your code is incorrect, you should re-read the documentation of ViewModel.
share: 'clock' specifies which ViewModel Share you want to use in that vm. It's not a property in itself.
share: 'clock'
So instead, you should have something like this:
Template.example2.viewmodel({ share: 'clock' onCreated: function() { console.log(this.initialTime()); } });
@cafe4it I wrote a repro with basically your code and all seems fine and working. What's the actual issue you are having?
https://github.com/arggh/viewmodel-share-test
No branches or pull requests
Hi, i try functions onCreated, autorun but not working
The text was updated successfully, but these errors were encountered: