Reactive MVVM
Source-generated [Reactive] properties with automatic UI updates via observables. No boilerplate required.
Build beautiful terminal applications with declarative layouts and reactive state management
dotnet add package Termina<PackageReference Include="Termina" Version="0.2.*" />// Define a ViewModel with reactive properties
public partial class CounterViewModel : ReactiveViewModel
{
[Reactive] private int _count;
public override void OnActivated()
{
Input.OfType<KeyPressed>()
.Subscribe(key =>
{
if (key.KeyInfo.Key == ConsoleKey.UpArrow) Count++;
if (key.KeyInfo.Key == ConsoleKey.DownArrow) Count--;
if (key.KeyInfo.Key == ConsoleKey.Q) Shutdown();
})
.DisposeWith(Subscriptions);
}
}
// Define a Page with declarative layout
public class CounterPage : ReactivePage<CounterViewModel>
{
protected override ILayoutNode BuildLayout()
{
return Layouts.Vertical()
.WithChild(
new PanelNode()
.WithTitle("Counter")
.WithContent(
ViewModel.CountChanged
.Select(c => new TextNode($"Count: {c}").Bold())
.AsLayout()
)
)
.WithChild(
new TextNode("Press ↑/↓ to change, Q to quit")
.WithForeground(Color.Gray)
);
}
}Termina brings modern application development patterns to terminal UIs: