There are several modules on page:
// module 1
require(['signalr'], function(s) {
s.subscribe('myhub1', function () { /* some code */ });
});
// module 2
require(['signalr'], function(s) {
s.subscribe('myhub2', function () { /* some code 2 */ });
});
And there is method that should be invoked after all modules are invoked (all subscribtions are done):
require(['signalr'], fuinction (s) { s.connect(); });
The possible solution is define modules and write like this:
// module 1
define('module 1', ['signalr'], function(s) {
s.subscribe('myhub1', function () { /* some code */ });
});
// module 2
define('module 2', ['signalr'], function(s) {
s.subscribe('myhub2', function () { /* some code 2 */ });
});
require(['signalr', 'module 1', 'module 2'], fuinction (s) { s.connect(); });
But the problem is that different pages has different modules, say:
page1.cshtml: module 1
page2.cshtml: module 1, module 2
So I can't write: require(['signalr', 'module 1', 'module 2'], fuinction (s) { s.connect(); }); because module 2 may not be defined on page2.cshtml.