Confessions of a hobbyist


#1

Hello community,

I have been using meteor since v0.6 or so.

In all these years, Meteor helped me to both find side jobs (aside of studying physics) and bring to life my own ideas. Some of the apps I’ve made have had a reasonable amount of success. In all these years I’ve stayed with meteor since it always changed at a fine, slow speed for me.

But now all my apps are still on version 1.6. The reason is that I cannot have any global variables in later versions. And that bugs me. For instance: I’ve always used the browser console very extensively during development, but now I cannot even access my collections anymore through the console… I do understand that it makes sense to encourage coding practice which aligns more with the rest of the js community. But that does not mean that one has to remove the ability to have global variables.

Maybe I am missing something, and it is still possible. In any case, I wanted to thank everyone for all these pieces of work that were done in support of this wonderful platform. And as for what I need it, there really is nothing quite like it out there still! I believe that Meteor is still uniquely positioned to get you started with some idea at a ridiculous pace.

I have the feeling that over all these years I’ve always just taken stuff, but never given something back. Hopefully that might change at some point.

Thank you and goodbye


#2

I think you can have globals, we certainly have them in a few places. The other thing you can do if you need those from the console is to import the file they are defined in in the console, for example:

/imports/ui/my-file.js

export MyCollection = ...

in the console you can do

require("/imports/ui/my-file.js").MyCollection

This works for packages too, though if its meteor you’ll need to prefix with meteor/ - basically exactly as you import files into one another, you can require them from the console


#3

Thanks for your answer, that’s certainly helpful. How exactly do I define globals? I used to do it with e.g.

Tasks = new Mongo.Collection('tasks')

…in a file located e.g. in the common directory (which runs on both client and server)


#4

hmm, you could try global.Tasks =


#5

Just remove the ecmascript and modules packages :smiley:


#6

It is annoying!
I usually create a script that for dev mode adds stuff I want to be able to debug from the console, example:

if (isDev()) {
    window._Tasks = Tasks;
}

(deliberately adding an underscore to not polute code)

Then from the console you can just access _Tasks.findOne() etc.


#7

Oh…thanks for that!
Max - seriously - you are a legend! Your work has helped me massively over all these years. Whenever I create a new app, your candy package is always a must-have. Thank you so much for everything :heart_eyes:


#8

Thanks, I’ll try that out!