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
-
I'd be better concerned about such argument syntax. It doesn't explicitly say which key placed where, so much reliance on order.
-
Voxera115854yThere seems to be some missing parentheses in the second, while the first has a semicolon in the place you should have a comma.
Especially parentheses can cause big problems as they can affect scope which can make the parser very sad.
Another thing is to try to avoid such large constructs and build the argument lite separately or avoid so many arguments in the first place and use an object instead.
Or build a list and use ... to send he list as arguments, that way you can build it in steps. -
Honestly, this is self induced. You can pare this into at least 3 sub operators that'll enable reuse and increase clarity. You can also move the side effects out of the pipe series by either creating a late binding operator or externalizing the observable creation and have separate subscribers and using takeUntil for cleanup.
Ex (shorthanded)
// This can also be curried to do a pseudo-strategy
private readonly getCompanyProject = (a,b,c,d) => pipe( // this is bat country
mergeMap(...),
mergeMap(...),
mergeMap(...),
mergeMap(...)
);
private readonly castastrophe = pipe(
ofType(...),
map(...) //Can probably just roll the cast in with filter,
filter(...)
)
...
this.actions$.pipe(
castastrophe,
getCompanyProject(...)
....
)
Some catch error love would also not be inappropriate here. Probably switchmap as well for abandoning intermediaries. -
hitko31484yThis is down to RxJS typings for pipe: it supports up to 9 generics, if you put more operations into a single pipe it basically tells you "You've got some serious spaghetti code going on there, nobody can reasonably follow through"
Related Rants
-
PonySlaystation0Be careful when you go down the rabbit hole of creating custom observables (rxJS). I wasted half a day just t...
-
twosliced4Why the shit is WebDev getting so complicated? It’s like everyone is just trying to show how smart they are ...
-
IHateForALiving7THE TALE OF THE CRAZED VISIONNAIRE Once upon a time some masochist woke up and snorted a gallon of glue. "I N...
Typescript is so fucking frustrating sometimes to deal with
The snippet above AND below do the EXACT SAME FUCKING THING. But because you double tap, it loses the fucking (not needed) type before the mapTo. If you aren't paying attention, you get this extremely fucking aggravating wall of red.
God damn it, can't this be better? RxJS is pretty fucking important, so why is this so god damned hard to just get some coherent fucking code highlighting!?
/rantover
rant
rxjs
why the fuck is this so bad
bad highlight
shit errors