在 SignalR 中链接承诺
Chaining promises in SignalR
这应该有效吗?我想在开始和完成之间链接读取功能。我无法让它工作。最终的 obj 只是一些内部 SignalR 对象。我正在使用 SignalR 2.2
var app = $.connection.appHub;
$.connection.hub.start()
.then(function() {
return app.server.read();
})
.done(function (obj) {
console.log(obj); // Should be the result from the read promise, but is not
}
所以应该可以。如果你的函数 'read' returns 一个值,你可以看到某事。
[HubName("appHub")]
public class AppHub : Hub
{
public string Read()
{
return "ok";
}
}
这应该有效吗?我想在开始和完成之间链接读取功能。我无法让它工作。最终的 obj 只是一些内部 SignalR 对象。我正在使用 SignalR 2.2
var app = $.connection.appHub;
$.connection.hub.start()
.then(function() {
return app.server.read();
})
.done(function (obj) {
console.log(obj); // Should be the result from the read promise, but is not
}
所以应该可以。如果你的函数 'read' returns 一个值,你可以看到某事。
[HubName("appHub")]
public class AppHub : Hub
{
public string Read()
{
return "ok";
}
}