Skip to content
This repository was archived by the owner on Dec 26, 2025. It is now read-only.
This repository was archived by the owner on Dec 26, 2025. It is now read-only.

[Question] No unsubscriptions for events in Blazored.Toasts.razor.cs #271

Description

@Mike-Lobbezoo

I have a general question, just out of curiosity.
I can see there are serveral events being hooked in the oninitialized() of the component ( Blazored.Toasts.razor.cs):

protected override void OnInitialized()
{
    ToastService.OnShow += ShowToast;
    ToastService.OnShowComponent += ShowCustomToast;
    ToastService.OnClearAll += ClearAll;
    ToastService.OnClearToasts += ClearToasts;
    ToastService.OnClearCustomToasts += ClearCustomToasts;
    ToastService.OnClearQueue += ClearQueue;
    ToastService.OnClearQueueToasts += ClearQueueToasts;

    if (RemoveToastsOnNavigation)
    {
        NavigationManager.LocationChanged += ClearToasts;
    }

    if (IconType == IconType.Custom
        && string.IsNullOrWhiteSpace(InfoIcon)
        && string.IsNullOrWhiteSpace(SuccessIcon)
        && string.IsNullOrWhiteSpace(WarningIcon)
        && string.IsNullOrWhiteSpace(ErrorIcon))
    {
        throw new ArgumentException("IconType is Custom but icon parameters are not set.");
    }
}

But I can't see them being unsubscribed or disposed, I get that this is a scoped service and events would eventually be cleaned up but wouldn't it be best practice to unsub from them anyway?

Forgive me if I'm getting this wrong.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionQuestion about this projectTriageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions