Skip to content

Commit

Permalink
Merge pull request #3858 from sbwalker/dev
Browse files Browse the repository at this point in the history
add variability for StreamRendering based on render mode
  • Loading branch information
sbwalker authored Feb 21, 2024
2 parents edcb240 + fa17e70 commit 85e289f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Oqtane.Client/UI/ModuleInstance.razor
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
@namespace Oqtane.UI
@inject SiteState SiteState

@if (PageState.RenderMode == RenderModes.Interactive || ModuleState.RenderMode == RenderModes.Static)
@if (PageState.RenderMode == RenderModes.Interactive || ModuleState.RenderMode == RenderModes.Interactive)
{
<RenderModeBoundary ModuleState="@ModuleState" PageState="@PageState" SiteState="@SiteState" />
<StreamRenderingDisabled ModuleState="@ModuleState" PageState="@PageState" SiteState="@SiteState" />
}
else
{
<RenderModeBoundary ModuleState="@ModuleState" PageState="@PageState" SiteState="@SiteState" @rendermode="@InteractiveRenderMode.GetInteractiveRenderMode(PageState.Site.Runtime, PageState.Site.Prerender)" />
<StreamRenderingEnabled ModuleState="@ModuleState" PageState="@PageState" SiteState="@SiteState" />
}

@code {
// this component is on the static side of the render mode boundary
// it passes state as serializable parameters across the boundary
// this enables the state to be used by downstream interactive components
[CascadingParameter]
protected PageState PageState { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions Oqtane.Client/UI/RenderModeBoundary.razor
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
</CascadingValue>

@code {
// this component is on the interactive side of the render mode boundary
// it receives state as serializable parameters so that the state can be made available to downstream components
private Type ModuleType { get; set; }
RenderFragment DynamicComponent { get; set; }

Expand Down
21 changes: 21 additions & 0 deletions Oqtane.Client/UI/StreamRenderingDisabled.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@attribute [StreamRendering(false)]

@if (PageState.RenderMode == RenderModes.Interactive || ModuleState.RenderMode == RenderModes.Static)
{
<RenderModeBoundary ModuleState="@ModuleState" PageState="@PageState" SiteState="@SiteState" />
}
else
{
<RenderModeBoundary ModuleState="@ModuleState" PageState="@PageState" SiteState="@SiteState" @rendermode="@InteractiveRenderMode.GetInteractiveRenderMode(PageState.Site.Runtime, PageState.Site.Prerender)" />
}

@code {
[Parameter]
public SiteState SiteState { get; set; }

[Parameter]
public PageState PageState { get; set; }

[Parameter]
public Module ModuleState { get; set; }
}
21 changes: 21 additions & 0 deletions Oqtane.Client/UI/StreamRenderingEnabled.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@attribute [StreamRendering(true)]

@if (PageState.RenderMode == RenderModes.Interactive || ModuleState.RenderMode == RenderModes.Static)
{
<RenderModeBoundary ModuleState="@ModuleState" PageState="@PageState" SiteState="@SiteState" />
}
else
{
<RenderModeBoundary ModuleState="@ModuleState" PageState="@PageState" SiteState="@SiteState" @rendermode="@InteractiveRenderMode.GetInteractiveRenderMode(PageState.Site.Runtime, PageState.Site.Prerender)" />
}

@code {
[Parameter]
public SiteState SiteState { get; set; }

[Parameter]
public PageState PageState { get; set; }

[Parameter]
public Module ModuleState { get; set; }
}

0 comments on commit 85e289f

Please sign in to comment.