Skip to content

Commit

Permalink
Work on blazor component
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed Jun 4, 2024
1 parent 9fc1e6b commit 1acad20
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/Shiny.Mediator.Blazor/BlazorEventCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@

namespace Shiny.Mediator.Blazor;

public class BlazorEventCollector(NavigationManager navigator) : IEventCollector, Microsoft.AspNetCore.Components.IComponentActivator
public class BlazorEventCollector(NavigationManager navigator) : IEventCollector, IComponentActivator
{
IComponent? currentComponent;


public IReadOnlyList<IEventHandler<TEvent>> GetHandlers<TEvent>() where TEvent : IEvent
{
navigator.LocationChanged += (sender, args) =>
{

};
navigator.RegisterLocationChangingHandler(async (context) =>
{
});
if (this.currentComponent is IEventHandler<TEvent> handler)
return [handler];

// TODO: no idea yet
return null;
return [];
}


public IComponent CreateInstance(Type componentType)
{
throw new NotImplementedException();
var component = (IComponent)Activator.CreateInstance(componentType);
this.currentComponent = component;

return component;
}
}
10 changes: 10 additions & 0 deletions src/Shiny.Mediator.Blazor/BlazorExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Shiny.Mediator.Blazor;

public static class BlazorExtensions
{
public static ShinyConfigurator UseBlazor(this ShinyConfigurator cfg)
{
cfg.Services.AddSingletonAsImplementedInterfaces<BlazorEventCollector>();
return cfg;
}
}

0 comments on commit 1acad20

Please sign in to comment.