Optional TUI launcher. Provide via hyperlink-ts/tui's layer. Missing →
TuiNotConfigured when a path has no CLI action.
export class class Tuiclass Tui {
key: Identifier;
Service: {
open: (input: TuiOpenInput) => Effect.Effect<void>;
};
}
Optional TUI launcher. Provide via hyperlink-ts/tui's layer. Missing →
TuiNotConfigured
when a path has no CLI action.
Tui extends import ContextContext.const Service: {
<Identifier, Shape = Identifier>(
key: string
): Service<Identifier, Shape>
<Self, Shape>(): <
Identifier extends string,
E,
R = Types.unassigned,
Args extends ReadonlyArray<any> = never
>(
id: Identifier,
options?:
| {
readonly make:
| ((
...args: Args
) => Effect<Shape, E, R>)
| Effect<Shape, E, R>
| undefined
}
| undefined
) => ServiceClass<Self, Identifier, Shape> &
([Types.unassigned] extends [R]
? unknown
: {
readonly make: [Args] extends [never]
? Effect<Shape, E, R>
: (
...args: Args
) => Effect<Shape, E, R>
})
<Self>(): <
Identifier extends string,
Make extends
| Effect<any, any, any>
| ((...args: any) => Effect<any, any, any>)
>(
id: Identifier,
options: { readonly make: Make }
) => ServiceClass<
Self,
Identifier,
Make extends
| Effect<infer _A, infer _E, infer _R>
| ((
...args: infer _Args
) => Effect<infer _A, infer _E, infer _R>)
? _A
: never
> & { readonly make: Make }
}
Creates a Context service key.
When to use
Use when you need to define a context service key for a dependency that must
be provided by the surrounding context.
Details
Call Context.Service("Key") for a function-style key, or use the two-stage
form Context.Service<Self, Shape>()("Key") for class-style service
declarations. The returned key can be yielded as an Effect and passed to
Context.make, Context.add, and the Context getter functions.
Gotchas
The string key is the runtime identity of the service. Reusing the same key
string for unrelated services makes them occupy the same slot in a
Context.
Example (Creating service keys)
import { Context } from "effect"
// Create a simple service
const Database = Context.Service<{
query: (sql: string) => string
}>("Database")
// Create a service class
class Config extends Context.Service<Config, {
port: number
}>()("Config") {}
// Use the services to create contexts
const db = Context.make(Database, {
query: (sql) => `Result: ${sql}`
})
const config = Context.make(Config, { port: 8080 })
Service<
class Tuiclass Tui {
key: Identifier;
Service: {
open: (input: TuiOpenInput) => Effect.Effect<void>;
};
}
Optional TUI launcher. Provide via hyperlink-ts/tui's layer. Missing →
TuiNotConfigured
when a path has no CLI action.
Tui,
{
readonly open: (
input: TuiOpenInput
) => Effect.Effect<void>
open: (input: TuiOpenInput(parameter) input: {
tree: CliTree;
path: ReadonlyArray<string>;
}
input: type TuiOpenInput = {
readonly tree: CliTree
readonly path: ReadonlyArray<string>
}
Input for
Tui.open
: the same Group (or record) the CLI was built from, plus the
member-key path to focus ([] = root grid, ["Mail"] = Mail detail).
TuiOpenInput) => import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<void>;
}
>()("hyperlink-ts/cli/Tui") {}