Context
I have been fiddling around and trying to create my own (just another) SPA framework. In this framework I've been trying to create a custom component loader to be able to do some dependency injection 'n stuff on the viewModels I'm loading.
Used KnockoutJS version: 3.3.0
Problem
The loadViewModel
function on the custom component loader isn't executing when a component is loaded.
Code for reference (see file):
injector(function (ko) {
ko.components.loaders.unshift({
getConfig: function (name, callback) {
var parts = name.split("/");
callback({
require: "components/" + name + "/" + parts[parts.length - 1]
});
},
loadViewModel: function (name, viewModelConfig, callback) {
console.log(arguments);
callback(null);
}
});
});
Please not that the injector
function is just some custom dependency resolver I wrote. (Almost like a define
or require
call on AMD components.)
The getConfig
function gets executed properly whatsoever.
For a complete overview of my doodling, see this git repo