react-async-states icon indicating copy to clipboard operation
react-async-states copied to clipboard

RFC: remove useAsyncState dependencies array

Open incepter opened this issue 3 years ago • 1 comments

The dependencies pattern is very useful and acts like a closure warrantee.

But it would create unintentional bugs and also would need to add things that should not depend on dependencies (events ... etc).

The goal is:

    1. Either completely remove the second argument of useAsyncState
    1. use it only on "certain" things to be defined.

To remove the dependencies, this means:

  • We should always keep track of the previous configuration
  • Every render, re-attach things like events, payload..., if the producer isn't the same, what to do if pending ?
  • What to do if "fork", "hoist" or "condition" changed ?

The problem about removing dependencies are usage like this:

useAsyncState(props => stateValue);

The inline producer's reference will certainly change every time... the only solution for this are dependencies.

Moreover, things like payload and events is safe to be independent from dependencies (or not ?) (useEvent will solve this particular use case)

This is not priority, but we should keep an eye on this.

incepter avatar Aug 01 '22 12:08 incepter

I think there are enough source and instance utilities to make this possible, deps will so serve only for auto running ?

incepter avatar Nov 09 '22 15:11 incepter