Identity Request Promises#93
Conversation
If `value` is given a `Promise`, the `PromiseState` will be pending until the `value` or `reason` is settled; otherwise, the `PromiseState` will be resolved immediately.
|
I realised now that for this to be useful value has to be a function that returns a promise, instead of a promise, otherwise it will recompute every time anything about props changes, which seeing as these are potentially expensive operations (that's why they're async in the first place) is a deal breaker. |
|
@nfcampos Good point. Need to think on that. |
|
Assuming that any function that is assigned to |
|
This is definitely not something that I need in every component but I've now hit a second situation where I'd have used this, do you think this belongs in react-refetch @ryanbrainard ? |
|
@nfcampos is your previous comment still valid?
Are you saying your would like this as is or wrapped in a function? |
|
|
|
Yeah, I think that makes sense, is simpler, and more consistent. Pulling this in. |
If
valueis given aPromise, thePromiseStatewill be pending until thevalueorreasonis settled; otherwise, thePromiseStatewill be resolved immediately.This was suggested in #92 as a possible solution to @nfcampos desire to load files like fetches. It should also be compatible the expectation @neezer had in #63 that static data loads immediately. I think this is a win-win. Thoughts?
Note, I played a little bit w/ trying to unify fetch requests and identity requests and cut down on the nested conditionals, but the
metahandling was getting in the way. If someone with morePromise-foo wants to take a stab at it, feel free :) Either way, I think the way it is now reads better, even though it is a bit verbose.