DEV Community

Discussion on: Building Side Effects in NGRX

Collapse
 
timdeschryver profile image
Tim Deschryver

Hi, is there a reason why ofType(closePriceSubscription.type) is used? I believe this is breaking the type-safety. I haven't checked this, so I might be wrong...

To preserve typesafe you can do:

ofType(closePriceSubscription),
switchMap(action => ...) // now, action knows it's a closePriceSubscription action
Collapse
 
gc_psk profile image
Giancarlo Buomprisco

You're totally right! I think I'd tried that and received some errors initially and then I switched to using .type. Might be because I was using an unstable version at the time :)