DEV Community

Discussion on: How to Test Five Common NgRx Effect Patterns

Collapse
 
lmfinney profile image
Lance Finney

I think there's a bug in an early example. I suspect you intended const x = y ? 1 : 0; to be const x === y ? 1 : 0;

Collapse
 
jdpearce profile image
Jo Hanna Pearce

No, y is the value I'm checking the value of, I'm then assigning 1 or 0 to x based on whether it's true or false respectively.

Collapse
 
lmfinney profile image
Lance Finney

Gotcha. I totally misread it. Sorry.

Thread Thread
 
isaacplmann profile image
Isaac Mann

This is part of why I don't like ternaries. Even if the person writing the ternary knows exactly what they're doing, someone else reading the ternary isn't sure that the writer actually meant what they wrote.

Thread Thread
 
jdpearce profile image
Jo Hanna Pearce

I think I'm just so used to them these days that it never occurs to me that they're unclear to anyone but junior devs. I like the brevity.

Having said that, I always read them with a subvocalised question intonation, so it always sounds like a "Really? Yes : No" in my head, which is maybe what has helped the pattern seem "obvious" to me.