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

Is there a way to close programatically from outside? #26

Closed
rik-iso opened this issue Dec 16, 2024 · 7 comments · Fixed by #32
Closed

Is there a way to close programatically from outside? #26

rik-iso opened this issue Dec 16, 2024 · 7 comments · Fixed by #32
Labels
enhancement New feature or request

Comments

@rik-iso
Copy link

rik-iso commented Dec 16, 2024

Love the library, using it for or all my recent modals.
qq though - is it possible to dismiss programatically from outside the callable?

The use case is using this to build a sort of floating toast warning the user they need to connect some payment information. The user can dismiss this toast via an X (-> call.end), but we also want to close it for them when they actually update their payment information.

Right now I figure I can pass in as a property to the callable something like an externally resolvable promise, and the Callable trigger call.end() internally when that resolves (i.e. resolve it externally if I want to close it earlier).... but wondering if I'm overlooking something simpler.

@rik-iso
Copy link
Author

rik-iso commented Dec 16, 2024

Feels like this might be something solved/handled with what's going on in this issue too: #21. i.e. it could be a singleton where I just "call" it again with a magic parameter which means "don't actually open".

@desko27 desko27 added the enhancement New feature or request label Dec 21, 2024
@desko27
Copy link
Owner

desko27 commented Dec 21, 2024

Hi @rik-iso, thanks for using the library!

I understand your use case. There's no proper API to handle this ATM, but I'd like to implement one.

One of the APIs I'm considering is expose the internal call id (someway) and use it to act on that specific call:

Toast.end(id, value)

Let me know if that would help!

@rik-iso
Copy link
Author

rik-iso commented Jan 5, 2025

I think it might. Alternatively, call always returns a promise, right? Could you use that reference as a proxy for the ID?

const promise = Toast.call()
// ...
Toast.end(promise, value) // internally you have a map of promise -> active toast

@desko27
Copy link
Owner

desko27 commented Jan 6, 2025

Hey, that looks so neat @rik-iso, I love the idea. Let's give it a try! Thanks!

@desko27
Copy link
Owner

desko27 commented Jan 21, 2025

I still have to write some docs for it, but I think #32 should do!

@desko27
Copy link
Owner

desko27 commented Jan 22, 2025

Released in v1.5.0!

@rik-iso
Copy link
Author

rik-iso commented Jan 31, 2025

Thanks so much! I literally needed this again today and checked in and you built it! Appreciate the turn around :)

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

Successfully merging a pull request may close this issue.

2 participants