Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Alert/Alert.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected override async Task OnInitializedAsync()
objRef ??= DotNetObjectReference.Create(this);
await base.OnInitializedAsync();

QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.alert.initialize", ElementId, objRef); });
QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.alert.initialize", ElementId, objRef), new RenderPriority());
}

[JSInvokable]
Expand Down
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Button/Button.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected override void OnInitialized()

base.OnInitialized();

if (!string.IsNullOrWhiteSpace(TooltipTitle)) QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.tooltip.initialize", ElementRef); });
if (!string.IsNullOrWhiteSpace(TooltipTitle)) QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.tooltip.initialize", ElementRef), new RenderPriority());
}

protected override async Task OnParametersSetAsync()
Expand Down
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Collapse/Collapse.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected override async Task OnInitializedAsync()
{
objRef ??= DotNetObjectReference.Create(this);

QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.collapse.initialize", ElementId, Parent, Toggle, objRef); });
QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.collapse.initialize", ElementId, Parent, Toggle, objRef), new RenderPriority());

await base.OnInitializedAsync();
}
Expand Down
11 changes: 6 additions & 5 deletions blazorbootstrap/Components/Core/BlazorBootstrapComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public abstract class BlazorBootstrapComponentBase : ComponentBase, IDisposable,
/// <summary>
/// A stack of functions to execute after the rendering.
/// </summary>
private Queue<Func<Task>>? renderQueue;
private PriorityQueue<Func<Task>, RenderPriority>? renderQueue;

#endregion

Expand Down Expand Up @@ -248,10 +248,11 @@ protected virtual ValueTask DisposeAsync(bool disposing)
/// Pushes an action to the stack to be executed after the rendering is done.
/// </summary>
/// <param name="action"></param>
protected void QueueAfterRenderAction(Func<Task> action)
/// <param name="renderPriority"></param>
protected void QueueAfterRenderAction(Func<Task> action, RenderPriority renderPriority)
{
renderQueue ??= new Queue<Func<Task>>();
renderQueue.Enqueue(action);
renderQueue ??= new PriorityQueue<Func<Task>, RenderPriority>();
renderQueue.Enqueue(action, renderPriority);
}

#endregion
Expand Down Expand Up @@ -385,6 +386,6 @@ public string? StyleNames
return styleNames;
}
}

#endregion
}
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Dropdown/Dropdown.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected override void OnInitialized()

base.OnInitialized();

QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.dropdown.initialize", ElementId, objRef); });
QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.dropdown.initialize", ElementId, objRef), new RenderPriority());
}

[JSInvokable]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected override async Task OnInitializedAsync()

await base.OnInitializedAsync();

QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.autocomplete.initialize", ElementRef, objRef); });
QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.autocomplete.initialize", ElementRef, objRef), new RenderPriority());
}

[JSInvokable]
Expand Down
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Modals/Modal.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected override async Task OnInitializedAsync()
objRef ??= DotNetObjectReference.Create(this);
await base.OnInitializedAsync();

QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.modal.initialize", ElementId, UseStaticBackdrop, CloseOnEscape, objRef); });
QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.modal.initialize", ElementId, UseStaticBackdrop, CloseOnEscape, objRef), new RenderPriority());
}

[JSInvokable]
Expand Down
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Offcanvas/Offcanvas.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected override async Task OnInitializedAsync()
objRef ??= DotNetObjectReference.Create(this);
await base.OnInitializedAsync();

QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.offcanvas.initialize", ElementId, UseStaticBackdrop, CloseOnEscape, IsScrollable, objRef); });
QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.offcanvas.initialize", ElementId, UseStaticBackdrop, CloseOnEscape, IsScrollable, objRef), new RenderPriority());
}

[JSInvokable]
Expand Down
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/PdfViewer/PdfViewer.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected override async Task OnInitializedAsync()
objRef ??= DotNetObjectReference.Create(this);
await base.OnInitializedAsync();

QueueAfterRenderAction(async () => await PdfViewerJsInterop.InitializeAsync(objRef!, ElementId!, scale, rotation, Url!));
QueueAfterRenderAction(async () => await PdfViewerJsInterop.InitializeAsync(objRef!, ElementId!, scale, rotation, Url!), new RenderPriority());
}

[JSInvokable]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected override async Task OnInitializedAsync()
{
objRef ??= DotNetObjectReference.Create(this);

QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.scriptLoader.initialize", ElementId, Async, ScriptId, Source, type, objRef); });
QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.scriptLoader.initialize", ElementId, Async, ScriptId, Source, type, objRef), new RenderPriority());

await base.OnInitializedAsync();
}
Expand Down
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Sidebar/Sidebar.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected override async Task OnInitializedAsync()

await base.OnInitializedAsync();

QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.sidebar.initialize", ElementId, objRef); });
QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.sidebar.initialize", ElementId, objRef), new RenderPriority());
}

[JSInvokable]
Expand Down
5 changes: 3 additions & 2 deletions blazorbootstrap/Components/Tabs/Tabs.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected override async Task OnInitializedAsync()

await base.OnInitializedAsync();

QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.tabs.initialize", ElementId, objRef); });
QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.tabs.initialize", ElementId, objRef), new RenderPriority());
}

[JSInvokable]
Expand Down Expand Up @@ -118,7 +118,8 @@ public void InitializeRecentTab(bool showTab)
if (showTab)
await ShowTabAsync(tab);
}
}
},
new RenderPriority()
);
}

Expand Down
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Toasts/SimpleToast.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected override async Task OnInitializedAsync()

await base.OnInitializedAsync();

QueueAfterRenderAction(async () => { await ShowAsync(); });
QueueAfterRenderAction(async () => await ShowAsync(), new RenderPriority());
}

[JSInvokable]
Expand Down
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Toasts/Toast.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected override async Task OnInitializedAsync()
objRef ??= DotNetObjectReference.Create(this);
await base.OnInitializedAsync();

QueueAfterRenderAction(async () => { await ShowAsync(); });
QueueAfterRenderAction(async () => await ShowAsync(), new RenderPriority());
}

[JSInvokable]
Expand Down
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Tooltip/Tooltip.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected override async Task OnInitializedAsync()

await base.OnInitializedAsync();

QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.tooltip.initialize", ElementRef); });
QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.tooltip.initialize", ElementRef), new RenderPriority());
}

protected override async Task OnParametersSetAsync()
Expand Down
8 changes: 8 additions & 0 deletions blazorbootstrap/Enums/Priority.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace BlazorBootstrap;

public enum Priority
{
High = 0,
Medium,
Low
}
19 changes: 19 additions & 0 deletions blazorbootstrap/Models/RenderPriority.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace BlazorBootstrap;

public record RenderPriority
{
public RenderPriority()
{
Priority = Priority.Low;
Order = DateTime.Now.Ticks;
}

public RenderPriority(Priority priority)
{
Priority = priority;
}

public Priority Priority { get; init; }

public long Order { get; init; }
}