Understanding ReactiveVar


#1

Why this isn’t work?
http://meteorpad.com/pad/mAgunJNpu9R2bDrmL/ReactiveVar%20Test

ReactiveVar isn’t like Session? How to make it behave like Session keys?

Thanks!


#2

ReactiveVar runs on the client whereas in that code snippet you have it on the server.

You can read the documentation for it here http://docs.meteor.com/#/full/reactivevar_pkg as well as this helpful article on reactivity https://www.discovermeteor.com/blog/reactivity-basics-meteors-magic-demystified/

I refactored your code a bit to make it work http://meteorpad.com/pad/zCSzNFfhET2S9MGtM/ReactiveVar%20example


#3

Can’t I share a state between client and server without Mongo.Collections?


#4

If you want read access to the shared state from client only, you can use collections or methods.
If you want read access to the shared state from client and server, you can use collections only.


#5

I reached some sort of solution for that, using Meteor.methods and a closer approach to Redux:

State can mutated by server “pure functions” and its replicated to the client state that is stored by a ReactiveDict then its propagated to Blaze template helpers since they are reactive computations.

Btw, thank you very much @tmikeladze for the article on reactivity link, helps a lot to understand how it works!