-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
提供事件总线的发布订阅 #17
Labels
Comments
修复一个订阅者订阅多个事件的情况 [EventSubscriber(IsAsync = true,Order =0, ThrowIfError =false)]
public class MyEventHandler4 : IEventSubscriber<MyEvent>, IEventSubscriber<MyEvent2>
{
private readonly ILogger<MyEventHandler4> _logger;
public MyEventHandler4(ILogger<MyEventHandler4> logger)
{
_logger = logger;
}
public Task HandleAsync(MyEvent @event, CancellationToken ct)
{
_logger.LogInformation($"muti msg 1 : {@event.Message}");
return Task.CompletedTask;
}
public Task HandleAsync(MyEvent2 @event, CancellationToken ct)
{
_logger.LogInformation($"muti msg 2 : {@event.Message}");
return Task.CompletedTask;
}
} |
vipwan
added a commit
that referenced
this issue
May 11, 2024
新增了一个`EventExtensions.cs`文件,定义了一个`EventExtensions`静态类,该类中定义了一个`PublishAsync`扩展方法,该方法允许`IEvent`类型的对象直接调用`PublishAsync`方法进行事件发布。 相关工作项: #1
提供IEvent的扩展,使得 事件可以脱离 public class MyEvent : IEvent
{
public string? Message { get; set; }
}
await new MyEvent { Message = "1234567890" }.PublishAsync(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
The text was updated successfully, but these errors were encountered: