With an Autobahn based stack (single server node) running WAMP for both RPC and PubSub, one option is like this:
var listInitialized = false;
session.subscribe("http://myapp.com/onListChange",
function (topic, event) {
if (listInitialized) {
// update list
}
}
});
session.call("http://myapp.com/getList").then(
function (res) {
// initial fill of list
listInitialized = true;
}
);
Since both the subscribe
and the call
run over a single WAMP connection (and that connection is an ordered WebSocket/TCP transport), the Autobahn server will setup the subscription and deliver events before the call is even processed. That subscription might yield events that arrive before the call returns, but these are ignored via the flag. Later, when the call returns and result has been processed, subsequent events are processed by the client.