Command

public protocol Command

Protocol for remote commands executed via command pattern. Registered in CommandRegistry with O(1) lookup by name.

  • Command name used for routing by CommandRegistry. The registry normalizes names by trimming whitespace and lowercasing before lookup, so implementations should provide a logical, case-insensitive name without leading/trailing whitespace.

    Declaration

    Swift

    var name: String { get }
  • Executes the command with the given payload.

    Declaration

    Swift

    func execute(payload: DataObject, completion: @escaping (CommandError?) -> Void) -> any Disposable

    Parameters

    payload

    The data to process.

    completion

    Called exactly once with nil on success or a CommandError on failure.

    Return Value

    A Disposable that cancels in-progress async work when disposed.