feat: add event bus
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Events
|
||||
{
|
||||
public interface EventBusInterface
|
||||
{
|
||||
void Subscrbe<T>(EventHandlerInterface<T> handler) where T : EventInterface;
|
||||
void Unsubscrbe<T>(EventHandlerInterface<T> handler) where T : EventInterface;
|
||||
void Publish<T>(T @event) where T : EventInterface;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Events
|
||||
{
|
||||
public interface EventHandlerInterface
|
||||
{
|
||||
}
|
||||
|
||||
public interface EventHandlerInterface<T> : EventHandlerInterface where T : EventInterface
|
||||
{
|
||||
void Handle(T @event);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Events
|
||||
{
|
||||
public interface EventInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Client.Domain.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Events
|
||||
{
|
||||
public class HeroCreatedEvent : EventInterface
|
||||
{
|
||||
public readonly Hero Hero;
|
||||
|
||||
public HeroCreatedEvent(Hero hero)
|
||||
{
|
||||
Hero = hero;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Client.Domain.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Events
|
||||
{
|
||||
public class HeroDeletedEvent : EventInterface
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Client.Domain.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Events
|
||||
{
|
||||
public class NpcCreatedEvent : EventInterface
|
||||
{
|
||||
public readonly NPC NPC;
|
||||
|
||||
public NpcCreatedEvent(NPC npc)
|
||||
{
|
||||
NPC = npc;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Client.Domain.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Events
|
||||
{
|
||||
public class NpcDeletedEvent : EventInterface
|
||||
{
|
||||
public readonly uint Id;
|
||||
|
||||
public NpcDeletedEvent(uint id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user