-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a22203
commit fd7a6c0
Showing
5 changed files
with
53 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 10 additions & 4 deletions
14
packages/Ignis.Components.WebAssembly/WebAssemblyHostContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
namespace Ignis.Components.WebAssembly; | ||
using Ignis.Components.Extensions; | ||
|
||
internal class WebAssemblyHostContext : IHostContext | ||
namespace Ignis.Components.WebAssembly; | ||
|
||
internal class WebAssemblyHostContext : HostContextBase | ||
{ | ||
public bool IsPrerendering => false; | ||
public override bool IsPrerendering => false; | ||
|
||
public override bool IsServerSide => false; | ||
|
||
public bool IsServerSide => false; | ||
public WebAssemblyHostContext(IEnumerable<IComponentExtension> componentExtensions) : base(componentExtensions) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Ignis.Components.Extensions; | ||
|
||
namespace Ignis.Components; | ||
|
||
public abstract class HostContextBase : IHostContext | ||
{ | ||
public abstract bool IsPrerendering { get; } | ||
|
||
public abstract bool IsServerSide { get; } | ||
|
||
public IEnumerable<IComponentExtension> ComponentExtensions { get; } | ||
|
||
protected HostContextBase(IEnumerable<IComponentExtension> componentExtensions) | ||
{ | ||
ComponentExtensions = componentExtensions ?? throw new ArgumentNullException(nameof(componentExtensions)); | ||
} | ||
|
||
public void OnComponentUpdate(IgnisComponentBase component) | ||
{ | ||
if (component == null) throw new ArgumentNullException(nameof(component)); | ||
|
||
foreach (var extension in ComponentExtensions) | ||
{ | ||
extension.OnUpdate(component); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
using Ignis.Components; | ||
using Ignis.Components.Extensions; | ||
|
||
namespace Ignis.Tests.Common; | ||
|
||
internal class TestHostContext : IHostContext | ||
internal class TestHostContext : HostContextBase | ||
{ | ||
public bool IsPrerendering => false; | ||
public override bool IsPrerendering => false; | ||
|
||
public bool IsServerSide => true; | ||
public override bool IsServerSide => true; | ||
|
||
public TestHostContext(IEnumerable<IComponentExtension> componentExtensions) : base(componentExtensions) | ||
{ | ||
} | ||
} |