Skip to content
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

Request to add support for promise status whether its resolved or rejected #88

Open
Tanmay2711 opened this issue Jul 2, 2020 · 2 comments

Comments

@Tanmay2711
Copy link

Hello Team,
usePromiseTracker hook provides only status about whether promise is in progress or not but we dont get to know if promise is resolved or rejected, I request to add one more feature to returned status of promise whether it is resolved or rejected or simple return array of promises that are tracked in that specific area. Is it possible to add this feature ?

@brauliodiez
Copy link
Member

Hello @Tanmay2711 the initial goal of react promise tracker was just to tell you if something was going on or not, we have planned to release a version that returns you a counter with the number of promises going on so far.

Your idea sounds interesting, but not sure which approach to follow to implement it, we could keep a stack of promises:

  • You could access it via some param in the hook.
  • How would it be worth for you? (track promise is global, and promises could belong to other places).
  • How long should we store that promise results?
  • What about identifying them?

Not sure if it would be better to make some error checking per promise or use some interceptor.

Could you ellaborate more on your scenario?

Thanks

@Tanmay2711
Copy link
Author

Hello @brauliodiez . Thanks for you reply. I really like react-promise-tracker, it helped me to resolve errors in my app due to manual state management. Though I came across scenario where I want to know promise I am tracking is resolved or rejected. I am using area based approach in my app. By passing specific area to trackPromise and usePromiseTracker hook. Suppose I am tracking one promise at specific area value, then usePromiseTracker hook should provide me information whether promise is resolved or rejected, it can be array of promise objects/ custom objects returned by the hook for the area that is passed and I can track multiple promises on same area.
hook should provide this information during the time span between promise started and completed as resolved or rejected,
for e.g.
const { promiseInProgress : True | False, promises : [{id:'promise1',status:resolved}, {id:'promise2',status:rejected}]} = usePromiseTracker({area:'MY AREA'});

It will be great help , if we can get information about promise's status whether it is resolved or rejected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants