rxjs#using TypeScript Examples
The following examples show how to use
rxjs#using.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Api.ts From majsoul-api with MIT License | 5 votes |
public subscribeToContestChatSystemMessages(id: number): Observable<any> {
console.log("subscribeToContestChatSystemMessages", id);
return using(
() => ({
unsubscribe: () => {
this.contestSystemMessagesSubscriptions[id]--;
if (this.contestSystemMessagesSubscriptions[id] > 0) {
return;
}
delete this.contestSystemMessagesSubscriptions[id];
this.lobbyService.rpcCall("leaveCustomizedContestChatRoom", {});
for (const id of Object.keys(this.contestSystemMessagesSubscriptions)) {
this.lobbyService.rpcCall<lq.IReqJoinCustomizedContestChatRoom>(
"joinCustomizedContestChatRoom",
{ unique_id: parseInt(id) }
);
}
}
}),
() => {
if (this.contestSystemMessagesSubscriptions[id] == null) {
this.contestSystemMessagesSubscriptions[id] = 1;
this.lobbyService.rpcCall<lq.IReqJoinCustomizedContestChatRoom>(
"joinCustomizedContestChatRoom",
{ unique_id: id }
).then((resp) => {
console.log(`tracking room '${id}'`, resp);
});;
} else {
this.contestSystemMessagesSubscriptions[id]++;
}
return this.notifications.pipe(
filter(
message => message.unique_id === id
// && message.constructor.name === "NotifyCustomContestSystemMsg"
)
);
}
);
}