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.