Picture of Matt Leathes
Re: Plugin - without registration
by Matt Leathes - Wednesday, 21 November 2018, 2:31 PM

Yes, _globals is just an object so you can add whatever you need to it.

You can test this stuff for yourself quite easily using the browser's console. If you have the adapt-devtools plugin installed you can just do:

var globals = a.course.get('_globals');
globals.hello = "hello world!";

If you don't have devtools plugin installed you'll need to do var a = require('core/js/adapt'); first.

Using the console in this way is a really good technique for having a bit of a poke around in the code I find.

As I mentioned earlier, the trick will be to hook into the right event so that you can execute your extension at the optimal time, load your data and add it into _globals before anything needs to use it. The Adapt.wait API may come in handy here.