Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@homo-lorens
It's kind of loosey goosey in the promise X|Y scenario. Personally, I think you'd get a lot more mileage out of the RxJs WebSocketSubject. Among other things it has the buffer to handle all the conditions you're already using.
In this example, you create a websocket connection. You send A messages, receive B|C messages.
B and C messages have individual streams that anyone with the service can observe, there's a separate stream for service errors.
If you wanted to you can also expose a railway by just creating a property that is result of calling asObservable on the subject. Consumers can specify their own behavior by simply calling subscribe
https://stackblitz.com/edit/...
Related Rants
Typescript is my new favorite and my grudge is the stupid scoping of type assertions. I have an async function that checks whether a variable is set and awaits a change event if it's undefined. This function is working javascript but invalid according to typescript, because it relies on the exact type changing while the function is running. I had to convert it to a mess of promises to bypass this because (and this is the best) the callback-based syntax of identical meaning will reset all type assertions, even locals that are never written after the callback's creation.
rant
type assertions
ts
wk239