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

[Feature Request] OnTimeout callback for toasts #149

Open
peter-mghendi opened this issue Nov 20, 2021 · 3 comments
Open

[Feature Request] OnTimeout callback for toasts #149

peter-mghendi opened this issue Nov 20, 2021 · 3 comments
Labels
Feature New feature that will be added to the project Needs: Design The issues needs design work before implementing

Comments

@peter-mghendi
Copy link

peter-mghendi commented Nov 20, 2021

Is your feature request related to a problem? Please describe.
I'm trying to show the user a time-constrained action they can take. I'm trying to use Blazored.Toast for this by making use of the timeout and onclick features. However, I'd like to be able to hook into the timeout process in order to perform a different action if the toast times out without the user clicking on it.

Describe the solution you'd like
An extra parameter of type Action? on the ToastService methods:

void ShowInfo(string message, string heading = "", Action? onClick = null, Action? onTimeout = null);

Example usage:

<button class="btn btn-info" @onclick="HandleClick">
    Info Toast with custom action on click
</button>

@code {
    private void HandleClick() 
    {
         toastService.ShowInfo("Click within 5 seconds", "Click me!", 
             onClick: () => /* User clicked within 5 seconds */, 
             onTimeout: () => /* User did not click within 5 seconds */);
    }
}

Describe alternatives you've considered
Not toast related. I conditionally show a button on the DOM, and get rid of it after the desired timeout.

Additional context
If this is considered to be a valid feature request, I'm fairly certain I can help to bring it over the finish line by adding an OnTimeout handler to _countdownTimer.OnElapsed here and removing the OnTimeout handler when the toast is clicked here (so that both are not called).

@peter-mghendi peter-mghendi added Feature Request Request to add a new feature Triage Issue needs to be triaged labels Nov 20, 2021
@ndambuki-j
Copy link

I'd love to have this feature

@Liero
Copy link

Liero commented Jan 3, 2022

What about when user clicks the close button, or the toast is closed programmatically (not possible right now, but most likely will be in the future)

I suggest OnClosed callback and if that's not enough, the callback pararameter can contain a Source property, or a OnTimeout callback can be implemented alongside

@peter-mghendi
Copy link
Author

@Liero I had not considered those scenarios. Your idea makes much more sense.

@chrissainty chrissainty added Feature New feature that will be added to the project Needs: Design The issues needs design work before implementing and removed Feature Request Request to add a new feature Triage Issue needs to be triaged labels Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature that will be added to the project Needs: Design The issues needs design work before implementing
Projects
None yet
Development

No branches or pull requests

4 participants