Does Meteor retain reactivity when using a REST API
Asked Answered
A

1

6

I am planning to use Qualtrics REST API, in order to get the data collected from a survey. Can i still retain Meteor's reactivity directly thru the rest api or should I save the data from the rest API into MongoDB to enable for real time updates within the app?

Any advice and further reading will be great.

This will sound like a noob question probably but I am just starting off with Meteor and JS as server side code and never used a web api before.

Agnate answered 2/1, 2014 at 17:36 Comment(0)
P
6

It entirely depends on what you do with the data it returns. Assuming you're either polling periodically or the API has some kind of push service (I've never heard of it before, so I have no idea), you would need to store the data it returns in a reactive data source: probably a Collection or Session variable, depending on how much persistence is required. Any Meteor templates that access these structures have reactivity built in, as documented here.

Obviously, you will probably need to be polling the API at an appropriately regular interval for this set up to work though. Take a look at Meteor.setInterval, or the meteor-cron package, which is probably preferable.

Pourparler answered 2/1, 2014 at 17:51 Comment(2)
Just to add to this, you can store your data in a reactive object and utilize the atmosphere package 'reactive'extra' for other reactive classes. github.com/boekkooi/reactive-extraTyranny
Is there a better way to achieve this? would MeteorStreams or ReactiveVar do the job?, thanksEnosis

© 2022 - 2024 — McMap. All rights reserved.