Skip to content

Enhance ToastService with async support and update documentation#1289

Merged
gvreddy04 merged 1 commit into
mainfrom
bugfix/836-toast-service-fix
Jul 3, 2026
Merged

Enhance ToastService with async support and update documentation#1289
gvreddy04 merged 1 commit into
mainfrom
bugfix/836-toast-service-fix

Conversation

@gvreddy04

Copy link
Copy Markdown
Contributor

This pull request introduces significant improvements to the Blazor Bootstrap Toasts component and its ToastService, focusing on enabling asynchronous toast notifications, clarifying documentation, and improving the user experience when handling multiple toast hosts and stack length behavior. The changes include a new NotifyAsync method for the ToastService, updates to the Toasts component to support async notifications, and comprehensive documentation and demo updates explaining the new capabilities and best practices.

Key changes:

ToastService Enhancements

  • Added an asynchronous NotifyAsync method to ToastService that allows publishing toast notifications and awaiting completion from all subscribers, supporting scenarios with multiple toast hosts. The internal event type was changed from Action<ToastMessage> to Func<ToastMessage, Task> to support async handlers.

Toasts Component Updates

  • Updated the Toasts component to subscribe to the new async event (OnNotifyAsync), updating the handler to be asynchronous and using InvokeAsync(StateHasChanged) for proper UI updates. The component now unsubscribes from the correct async event during disposal.
  • Improved stack length behavior: When the toast stack exceeds its limit, the oldest rendered toasts are dismissed first, and visible toasts complete their hide transition before being removed from the stack.

Documentation and Demo Improvements

  • Added a new demo (ToastService_Demo_01_NotifyAsync_With_Multiple_Subscribers.razor) showing how to use NotifyAsync with multiple toast hosts and updated the main ToastService documentation and usage notes to explain when to use Notify vs. NotifyAsync.
  • Clarified and expanded documentation for stack length and toast removal behavior in both the Blazor app and the Markdown docs.
  • Added callouts and tips in the documentation to guide users on choosing between Notify and NotifyAsync based on their scenario.
  • Updated demo links and metadata in the documentation for accuracy and clarity.

These changes provide a more robust, flexible, and well-documented toast notification system for Blazor applications.

@gvreddy04 gvreddy04 added this to the 4.0.0 milestone Jul 3, 2026
@gvreddy04 gvreddy04 self-assigned this Jul 3, 2026
@gvreddy04 gvreddy04 added bug Something isn't working enhancement New feature or request labels Jul 3, 2026
@gvreddy04

Copy link
Copy Markdown
Contributor Author

#839

@gvreddy04 gvreddy04 merged commit 0be17e3 into main Jul 3, 2026
1 of 3 checks passed
@gvreddy04 gvreddy04 deleted the bugfix/836-toast-service-fix branch July 3, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant