easy-peasy icon indicating copy to clipboard operation
easy-peasy copied to clipboard

unstable_effectOn handler type signature does not allow returning void

Open no-stack-dub-sack opened this issue 3 years ago • 2 comments

Hi, thanks for the excellent work on this library! I've been really enjoying using it so far and its making introducing my team to React w/ state management a less overwhelming experience than it would be using the typical vanilla redux stack (let alone introducing something like redux-saga or redux-observables). easy-peasy is certainly making this more approachable 👍

On to this issue:

I noticed when using unstable_effectOn that I'm unable to just return void when the handler does not need a dispose function, instead the type signature requires me to explicitly return undefined:

export const todosListener: unstable_EffectOn<TodoModel> = unstable_effectOn(
  [(state) => state.todos],
  (actions, change) => { // error! Type 'void' is not assignable to type 'Dispose | undefined'.
    const [items] = change.current;
    actions.doSomethingSynchronous();
    // return undefined;
  },
);

Not sure if there are any other implications, but this could be a quick fix here:

+   ) => undefined | void | Dispose,
-   ) => undefined | Dispose,

Happy to submit a PR if this is something you'd consider. Thanks!

no-stack-dub-sack avatar Jan 12 '22 03:01 no-stack-dub-sack

@ctrlplusb just checking in on this. Is this something you'd be willing to accept a PR for? A small change but could be helpful for other users as well. Also, curious about how well this project is currently being supported and if there are plans for any future releases. I know maintaining OS projects can be a lot, so if you're also looking for help maintaining, please let me know.

Thanks again!

no-stack-dub-sack avatar Jan 25 '22 19:01 no-stack-dub-sack

Hi @no-stack-dub-sack - stoked to hear that the library is useful. I'll happily consider any PR that improves the type definitions. Thanks! :)

ctrlplusb avatar Feb 08 '22 15:02 ctrlplusb