Static helpers for working with IComponent and IComponent<TResult> in parent model Update methods.
More...
|
| static T | Component |
| | Initialise a component and dispatch its startup command if any.
|
| static ? T | Next |
| | Delegate an IMsg to component and return the updated component (typed) alongside the optional follow-up command.
|
Static helpers for working with IComponent and IComponent<TResult> in parent model Update methods.
These methods exist to eliminate the cast boilerplate that would otherwise be required when delegating Update calls to a typed component field:
var (next, cmd) = myPage.Update(msg);
var typed = (MyPage)next;
var (next, cmd) =
Component.Delegate(myPage, msg);
static T Component
Initialise a component and dispatch its startup command if any.
Definition Component.cs:79
◆ IsCompleted< TResult >()
| bool ConsoleForge.Core.Component.IsCompleted< TResult > |
( |
[NotNullWhen(false)] this IComponent< TResult >? | component | ) |
|
|
static |
Returns true if component has completed — i.e.
its IComponent<TResult>.Result is non-null. Safe to call on a null reference; returns false.
- Template Parameters
-
| TResult | The component's result type. |
- Parameters
-
| component | The component to check, or null. |
◆ Component
| T ConsoleForge.Core.Component.Component |
|
static |
Initialise a component and dispatch its startup command if any.
Equivalent to calling IModel.Init and passing the result to Cmd.Batch.
- Template Parameters
-
| T | Concrete component type. |
- Parameters
-
| component | The component to initialise. |
| extraCmds | Additional commands to batch alongside the component's own init command. |
- Returns
- The same component reference (init is side-effect-free) and the combined startup command, or
null if none.
◆ Next
| ? T ConsoleForge.Core.Component.Next |
|
static |
Delegate an IMsg to component and return the updated component (typed) alongside the optional follow-up command.
Returns (null, null) when component is null.
- Template Parameters
-
| T | Concrete component type (must implement IComponent). |
- Parameters
-
| component | The component to update, or null. |
| msg | The message to process. |
- Returns
- The updated component cast back to T and the optional ICmd to dispatch. Both are null when the component is null.
- Exceptions
-
| InvalidCastException | Thrown if the component's Update implementation returns a different concrete type than T . Components must return this with { … } (a new instance of the same type). |
The documentation for this class was generated from the following file:
- src/ConsoleForge/Core/Component.cs