refactor(app): compose live presentation startup

This commit is contained in:
Erik 2026-07-22 17:55:15 +02:00
parent aa6ffa5176
commit 88f32dc4e2
23 changed files with 1767 additions and 626 deletions

View file

@ -21,4 +21,31 @@ internal sealed class LiveEntityRuntimeSlot : ILiveEntityRuntimeSource
throw new InvalidOperationException("The live entity runtime is already bound.");
Current = runtime;
}
public IDisposable BindOwned(LiveEntityRuntime runtime)
{
Bind(runtime);
return new Binding(this, runtime);
}
private void Unbind(LiveEntityRuntime expected)
{
if (ReferenceEquals(Current, expected))
Current = null;
}
private sealed class Binding : IDisposable
{
private LiveEntityRuntimeSlot? _owner;
private readonly LiveEntityRuntime _expected;
public Binding(LiveEntityRuntimeSlot owner, LiveEntityRuntime expected)
{
_owner = owner;
_expected = expected;
}
public void Dispose() =>
Interlocked.Exchange(ref _owner, null)?.Unbind(_expected);
}
}