Files
ShrinkEventBus/Runtime/ShrinkEventBusBuilder.cs
T
cneicy 1c921f5aec
Publish UPM package / publish (push) Failing after 1s
chore: initialize standalone UPM package
2026-08-26 02:50:18 +08:00

37 lines
1.2 KiB
C#

#nullable enable
using System;
namespace ShrinkEventBus
{
public sealed class ShrinkEventBusBuilder
{
internal ShrinkBusKey Key { get; private set; } = ShrinkBusKey.Game;
internal ShrinkBusOptions Options { get; private set; } = ShrinkBusOptions.Inline();
internal Action<IShrinkEvent, Type, ShrinkBusKey>? PostObserver { get; private set; }
public ShrinkEventBusBuilder WithKey(ShrinkBusKey key)
{
Key = key;
return this;
}
public ShrinkEventBusBuilder WithOptions(ShrinkBusOptions options)
{
Options = (options ?? throw new ArgumentNullException(nameof(options))).CloneValidated();
return this;
}
public IShrinkEventBus Build() => Options.Scheduler == ShrinkBusSchedulerKind.Inline
? new ShrinkInlineEventBusInstance(this)
: new ShrinkEventBusInstance(this);
internal ShrinkEventBusBuilder WithPostObserver(
Action<IShrinkEvent, Type, ShrinkBusKey> observer)
{
PostObserver = observer ?? throw new ArgumentNullException(nameof(observer));
return this;
}
}
}