I'm trying to built a chat frontend with rsocket-websocket-client. I'm able to send message from frontend using requestChannel(new Flowable(source...))
and receive message using requestChannel(new Flowable.just({metatdata}))
.
I was trying to use FlowableProcessor
to reduce two invocations of requestChannel
into one.
Couldn't find documentation on FlowableProcessor
for rsocket.
Here is my attempt:
const processor = new FlowableProcessor(
new Flowable(source => {
source.onSubscribe({
cancel: () => {},
request: n => {}
});
source.onNext({
metadata: constructMetadataWithChannelId(channelId),
});
})
);
sock.requestChannel(processor.map(item => item))
.subscribe({
onComplete: () => {
console.log(
`complted subscribe`,
);
},
onError: error1 => {
console.log(
`subscriber err: ${error1}`,
);
},
onSubscribe: subscription => {
console.log(
`onSubscribe`,
);
setConnectStatus('connected');
setChannelIdDone(true);
subscription.request(1000);
},
onNext: (val: any) => {
const value = JSON.parse(val) as Message;
console.log(
`received event from channel: ${JSON.stringify(
value,
)}`,
);
}
})
I understand it's type issue. Not able to figure out where processor.map(item => item)
is erroring out.
TS2345: Argument of type 'IPublisher<unknown>' is not assignable to parameter of type 'Flowable<Payload<Buffer, Buffer>>'.
Type 'IPublisher<unknown>' is missing the following properties from type 'Flowable<Payload<Buffer, Buffer>>': lift, take