I'm incorporating SignalR into a project where I'm already using require.js to handle my scripts dependencies.
I'm having a little trouble making sure "/signalr/hubs" is called after "jquery.signalR-1.1.2" loads.
I got it to work, but I'm wondering if there is a better alternative out there.
This is what I have:
require(["signalr"], function () {
require(["noext!/signalr/hubs"], function () {
//initialize and work with the hub here
}
}
Is there a way I can create a shim here to establish the dependency between signalr/hubs and the signalr script?
Thanks!
This works for me with SignalR 1.1.2:
require.config({
baseUrl: "/<your scripts dir>",
paths: {
"jquery": "jquery-<your jquery version>.min",
"signalr.core": "jquery.signalR-<your signalr version>.min",
"signalr.hubs": "/signalr/hubs?"
},
shim: {
"jquery": {
exports: "$"
},
"signalr.core": {
deps: ["jquery"],
exports: "$.connection"
},
"signalr.hubs": {
deps: ["signalr.core"],
}
}
});
require(["jquery", "signalr.hubs"],
function($)
{
var hubProxy = $.connection.myHub;
// ... go to town ...
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With