ConsoleForge 0.3.0
Elm-architecture TUI framework for .NET 8
Loading...
Searching...
No Matches
ConsoleForge.Core.IComponent< out TResult > Interface Template Reference

A self-contained sub-program that can signal completion by setting Result to a non-null value. More...

Inheritance diagram for ConsoleForge.Core.IComponent< out TResult >:

Properties

TResult Result [get]
 The result value produced when this component completes.

Additional Inherited Members

Public Member Functions inherited from ConsoleForge.Core.IModel
ICmdInit ()
 Called once at program start.
IWidget View ()
 Produce the root widget for the current model state.
Public Attributes inherited from ConsoleForge.Core.IModel
IModel Model
 Pure update function.

Detailed Description

A self-contained sub-program that can signal completion by setting Result to a non-null value.

Template Parameters
TResultThe type of value produced when the component completes (e.g. string for a file picker, bool for a confirm dialog).

When Result is non-null the component is considered completed. The parent model should inspect the result in its own Update loop and transition state accordingly:

// FilePicker returns the chosen path on completion
public sealed record FilePicker : IComponent<string>
{
public string? Result { get; init; }
// ... Init, Update, View
}
// Parent model embeds the picker and handles its result
record AppModel(FilePicker? Picker, string? ChosenFile) : IModel
{
public (IModel Model, ICmd? Cmd) Update(IMsg msg)
{
if (Picker is not null)
{
var (next, cmd) = Component.Delegate(Picker, msg);
if (next.IsCompleted())
return (this with { Picker = null, ChosenFile = next.Result }, cmd);
return (this with { Picker = next }, cmd);
}
// ... root-level handling
}
}
TResult Result
The result value produced when this component completes.
Definition IComponent.cs:105
A self-contained sub-program: owns its own state, update logic, and view.
Definition IComponent.cs:53
IModel Model
Pure update function.
Definition IModel.cs:23
delegate Task< IMsg > ICmd()
A command: an async function that produces one message when complete.

Property Documentation

◆ Result

TResult ConsoleForge.Core.IComponent< out TResult >.Result
get

The result value produced when this component completes.

null while the component is still running. Once non-null the component is considered done; the parent should read the result and decide what happens next.


The documentation for this interface was generated from the following file:
  • src/ConsoleForge/Core/IComponent.cs