Basically, I have a couple of REST calls I need results from, and then use that result before and inside my require() call. Currently, I've instructed the REST calls ($.getJSON) to be non-async, with:
$.ajaxSetup({
async: false
});
But, since this is not optimal, I'm wondering how the pattern looks like for them calls to be async (or rather the functions that call them).
Current (psuedo) code:
var pageConfig = getPageConfig(document); //this function calls a REST API
var appsConfig = getAppsConfig(pageConfig.appid); //this function calls another REST API
require.config( {
//do some stuff here with pageConfig and appsConfig
});
require( ["somelib", "jquery"], function(somelib) {
//do some MORE stuff here with pageConfig and appsConfig
});
I know this is probably not an optimal way of doing it, so I'm looking for options.