What I'm trying to achieve is something like this, but I'm not sure how to go about it:
define([
// Load basic modules that are always used
], function (one, two, ...) {
if (a) {
// Load this extra module as "extraModule"
}
else {
// Load that extra module as "extraModule"
}
// Be able to use functions from extraModule without worrying
// exactly what they do
extraModule.doTheThing();
Then the two options for extraModule would behave as though they were objects inheriting from the same abstract class.
Does anyone know if this is possible with Dojo?
I think the closest way to achieve this is by doing the following:
define([ "one", "two", "extraModule1", "extraModule2" ], function(one, two, extra1, extra2) {
var extra = null;
if (a) {
extra = extra1;
} else {
extra = extra2;
}
});
So you just load both modules and pick the one you need afterwards.