No need to subscribe inside an autorun block if your subscription does not take parameters?

#1

Hello,

I am using Blaze and on template.onCreated, I am subscribing to a subscription.
Is it needed to be inside an autorun block if the subscription does not take parameters?

I think no but I am not sure.

Best

#2

An autorun will rerun only if there are reactive variables inside. So, in a simple subscription with no parameters or with non-reactive parameters, an autorun is unnecessary.

1 Like
#3

I think it’s also worth mentioning that autorun does also execute when data in the subscription is changed on the server, parameters or lack thereof notwithstanding. This is useful for triggering client-side logic (e.g. push notifications).