rxjs/webSocket should support deserializer return Promise
Open
@benlesh is already working on this.
Since Sep 1, 2020.
- Dominant language
- TypeScript
- Stars
- 31.7k
- Forks
- 3k
- PR merge metrics
- No merged PRs in 30d
Description
Feature Request
rxjs/webSock should support deserializer return Promise
Is your feature request related to a problem? Please describe.
import { webSocket } from 'rxjs/webSocket'
const api = (options) => {
const subject = webSocket(options);
return {
subscribe: (params: any) => {
const observableA = subject.multiplex(
() => params,
() => ({ close: true }),
(message: any) => {
return message.requestId === params.requestId
}
);
return observableA
}
}
}
const ws = api({
url: 'ws://127.0.0.1:50055/ws/v2',
protocol: 'json',
binaryType: 'blob',
deserializer: ({ data }) => {
return new Promise((res, rej) => {
const reader = new FileReader()
reader.readAsText(data)
reader.onload = () => {
res(JSON.parse(reader.result))
}
})
}
})
ws.subscribe({requestId: '1', data:{}})
.subscribe((res) => {
console.log('res', res);
})
the deserializer have to return Promise because i have to resolve Blob, but socket.onmessage doesn't support deserializer function to return Promise
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.