-
Notifications
You must be signed in to change notification settings - Fork 27
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
onReady callback causes infinite loop in template.autorun #71
Comments
Onready makes the autorun useless so just call it outside. |
If I don't use autorun, then the subscription doesn't rerun when a parameter the subscription depends on gets updated. In the example above: template.userLimit.get() |
Okay I overlooked this. In such case, would it work if you omit assigning the subscription value to a variable that is declared inside autorun? Furthermore, I would also try to play with Template.users.onCreated(function() {
const template = this
template.usersReady = new ReactiveVar(false)
template.userLimit = new ReactiveVar(10)
template.autorun(function() {
console.log('AUTORUN')
// avoid introducting a new reactive data source:
subsCache.subscribe('users', template.userLimit.get(), {
onReady: function () {
// avoid deps.changed call by using:
Tracker.nonReactive(() => template.usersReady.set(true))
}
})
})
}) Does that help? I am just asking this much to see, if the issue is rather a Blaze/Tracker issue or if it's really caused by this package. |
Tried your code sample. It still goes into an infinite loop. Not assigning the variable also wouldn't be ideal, because further manipulation of that cached subscription would then not be possible. |
Sample code below with onReady callback goes into an infinite AUTORUN loop:
The code below does not:
The text was updated successfully, but these errors were encountered: