Standalone Minimongo Cursors not reactive

Hi everyone,

I teach a web programming course to high school students and use building Meteor applications as the end goal. This year our school has put on some strict restrictions on all of our OS X computers (teacher and student) on installation rights and the use of certain applications. Terminal access and (workarounds like scripts through Automator) is strictly forbidden - obviously a problem for creating Meteor apps.

The first semester of the course was all HTML, CSS, Javascript, and jQuery, and I’ve been able to have students add libraries with script tags in the HTML file. We’ve done some work with standalone Blaze, and I also was able to find and figure out how to get the required libraries from minimongo into the page to teach the basics of accessing a MongoDB.

The obvious next step is to connect the two together. The problem I’ve run into is that the minimongo cursors don’t seem to be reactive. I’d like to be able to teach students to use helpers in templates. Students have used reactive variables from Blaze as helpers, and those work just fine. Students can also access a database that is loaded into minimongo with an initial page load, and use {{#each}}, {{#with}}, and other helpers.

Here’s my problem: I’d expect that this query to the database would be reactive like it is in a Meteor app when the database changes. The cursors do not rerun when there is an insert or update. I’ve created a Github repo to show the problem I am having here:

https://github.com/emwdx/mileauxGrade/

Here is the problem:

  • There is initially a single grade in the database, and this shows up on page load.
  • When you insert another grade, the new grade shows up in the list because I used a reactive variable called allGrades for that helper instead of Grades.find().
  • The mathGrade, which is determined by a Grades.find({course:‘math’}) as I would use in a Meteor app, does not update reactively.
  • From Grades.find().fetch() in the console, the new grade is present there

I thought that Blaze automatically saw all Minimongo cursors as reactive. I would like to be able to use the helper the same way as we do in regular Meteor apps, but not in a Meteor project.

Here are my two questions:

  • Am I doing something wrong that is resulting in Minimongo cursors not being reactive? I’ve tried a number of different Tracker.autorun combinations, none of which have worked. I fully admit this is the likely case.

  • Is there an easy way to get the meteor build tool to package libraries together for inclusion in a page as one would include jQuery or backbone? I’d love to include Blaze, minimongo, reactive-var, etc in an HTML file without having to parse through Package.js files to figure out what has to be loaded and in which order.

I also realize MeteorPad is another way around the OS X installation issue, but the site is slow when accessed from China. It works, but it’s nothing like being able to do everything locally.

Mh, I am a little stuck on the restrictions. Can’t you use educational Linux boot-usb sticks? They are intended for learning, system isolated and persistent (i.e. able to set up once with meteor installed etc)
https://sevenbits.github.io/Mac-Linux-USB-Loader/

Or run on a machine in the network a bunch of docker containers and have them use a terminal Web emulator to ssh into the machine… might be overkill

Regarding your question: There is no separate, literate way to build for clients. What you could do, is create a meteor boilerplate app on your machine, in the same network, and have all collections auto published. Than have the kids on their machine connect to your server. They could download and extend the browser js and html - though there is no build process for I.e. Handlebars. A separation of Meteor core modules into npm modules is on the (distant) agenda which would make this build independent.

But if I were you, I would try to get to a dev environment for the kids first. Also, cloud ide’s could be an option such as c9 AWS Cloud9 Amazon Web Services (which might by faster for China than meteorpad)*they do provide a free tire for public workspaces

Edit:
Here is the blog post I was looking for: AWS Cloud9 Amazon Web Services

And the forum discussion earlier here (especially last post)

This is a great suggestion. Obviously booting into a Linux OS is going to be an easy way to get around those restrictions, and I haven’t thought about that. Thanks for sharing the resources.

I’m still surprised though that it’s not currently easy to make minimongo cursors reactive. I’ve been looking for the place where this happens in Meteor and I assume it has to do with publications/subscriptions. I see that the LocalCollections object has some observe methods that might be used with autorun to do this. I’d love some help if anyone could show me how to do this.

I just happen to be watching the latest Meteor Night now and am learning about the separation of modules you mentioned. Thanks for the ideas, @dinos.