Angular: RxStomp .Watch .Subscribe 方法
Angular: RxStomp .Watch .Subsribe Method
我不知道如何使用 RxStomp
中的 watch
方法。
subscribeToOtherAccount(otherAccount): string {
const channelId = ChannelService.createChannel(this.username, otherAccount.username);
this.rxStompService.watch('/channel/chat/' + channelId).subscribe((message: Message) => {
this.messageService.pushMessage(message);
})
return channelId
}
我收到这个错误:
TS2769: No overload matches this call. Overload 1 of 5, '(observer?: PartialObserver): Subscription', gave the following error.
Argument of type '(message: Message) => void' is not assignable to parameter of type 'PartialObserver'.
Property 'complete' is missing in type '(message: Message) => void' but required in type 'CompletionObserver'.
Overload 2 of 5, '(next?: (value: IMessage) => void, error?: (error: any) => void, complete?: () => void): Subscription', gave the following error. Argument of type '(message: Message) => void' is not assignable to parameter of type '(value: IMessage) => void'.
Types of parameters 'message' and 'value' are incompatible.
Type 'IMessage' is missing the following properties from type 'Message': channel, sender, content types.d.ts(64, 5): 'complete' is declared here.
任何人都可以给我提示或 link 示例吗?
subscribeToOtherAccount(otherAccount): string {
const channelId = ChannelService.createChannel(this.username, otherAccount.username);
this.rxStompService.watch(`/channel/chat/${channelId}`).subscribe(res => {
const data: Message = JSON.parse(res.body);
this.messageService.pushMessage(data);
})
return channelId;
}
我不知道如何使用 RxStomp
中的 watch
方法。
subscribeToOtherAccount(otherAccount): string {
const channelId = ChannelService.createChannel(this.username, otherAccount.username);
this.rxStompService.watch('/channel/chat/' + channelId).subscribe((message: Message) => {
this.messageService.pushMessage(message);
})
return channelId
}
我收到这个错误:
TS2769: No overload matches this call. Overload 1 of 5, '(observer?: PartialObserver): Subscription', gave the following error. Argument of type '(message: Message) => void' is not assignable to parameter of type 'PartialObserver'. Property 'complete' is missing in type '(message: Message) => void' but required in type 'CompletionObserver'. Overload 2 of 5, '(next?: (value: IMessage) => void, error?: (error: any) => void, complete?: () => void): Subscription', gave the following error. Argument of type '(message: Message) => void' is not assignable to parameter of type '(value: IMessage) => void'. Types of parameters 'message' and 'value' are incompatible. Type 'IMessage' is missing the following properties from type 'Message': channel, sender, content types.d.ts(64, 5): 'complete' is declared here.
任何人都可以给我提示或 link 示例吗?
subscribeToOtherAccount(otherAccount): string {
const channelId = ChannelService.createChannel(this.username, otherAccount.username);
this.rxStompService.watch(`/channel/chat/${channelId}`).subscribe(res => {
const data: Message = JSON.parse(res.body);
this.messageService.pushMessage(data);
})
return channelId;
}