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

Check Promise status #4

Closed
plckr opened this issue Sep 10, 2021 · 2 comments
Closed

Check Promise status #4

plckr opened this issue Sep 10, 2021 · 2 comments

Comments

@plckr
Copy link

plckr commented Sep 10, 2021

Hello once again,

Looking at the documentation I could not find the answer.
I'm trying to implement a loading inside my modal, after the user submits (resolves, or rejects the promise)

For that, I thought about know if the Promise is Pending or Resolves/Rejected
if Resolves/rejected the loading should appear

I suggest add a isPending property for example

Example code after the implementation

{!isPending && <span>Loading ...</span>}
@supnate
Copy link
Collaborator

supnate commented Sep 11, 2021

You may need use a separate state for such cases:

const [pending, setPending] = useState(false);
const showModal = () => {
  setPending(true);
  modal.show(MyModal, {}).then(() => {
    setPending(false);
  }
}

Or, you just handle pending state inside a modal.

@plckr
Copy link
Author

plckr commented Sep 11, 2021

This is the solution I first remembered. But thought you wanted to implement inside the library.
In that case this issue can be closed 👍

@supnate supnate closed this as completed Jan 9, 2022
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