-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable RemoteData to take a promise #5
Comments
@isaacseymour I feel like you might have thoughts :) |
Also if we did this it might be nice to hide the actual class under the hood and turn the top level API into: import { withPromise, withFetch } from 'remote-data-js'
const remoteData = withPromise(promise, { onChange })
const remoteData = withFetch(url, {onChange, fetchOptions, ...}) Would prevent more breaking changes in the future. |
Hi @jackfranklin Any updates with this? |
No - not yet! PRs' welcome :) |
You can now do Not yet got the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Under the hood right now Remote Data uses
fetch
directly, but in many real world apps (like the one I'd like to use this in!) this is a problem, because we use our own API client that has special headers, etc, etc set up.Rather than pass all this into RemoteData it would be much better if along with calling
fetch
you could also give it a promise that should resolve or error accordingly.Doing this would:
RemoteData
that's immediately in thePENDING
state (and not fire anonChange
for theNOT_ASKED
=>PENDING
transitionSUCCESS
and provide whatever the promise resolved with as the dataFAILURE
and provide the error data.I think this should be a new method on
RemoteData
? Could be something like:The text was updated successfully, but these errors were encountered: