79434729

Date: 2025-02-12 23:38:43
Score: 0.5
Natty:
Report link

I ended up changing fooSelector to return a bogus value instead of throwing. Basically something like:

export const fooSelector = createSelector(
  inputSelector1,
  inputSelector2,
  inputSelector3,
  (
    input1: Input1,
    input2: Input2,
    input3: Input3,
  ): Foo => {
    if (!isValid(input1, input2, input3)) {
      // not a valid Foo, so anything that tries to use this will throw
      // an error
      return {} as Foo;
    }

    // combine input1, input2, input3 like before
  }
);
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: MageWind