@dxos/compute - v0.16.0
    Preparing search index...

    Variable withHandlerConst

    withHandler: {
        <Def extends Operation.Definition<any, any, any>, E = never>(
            handler: Handler<
                Operation.Definition.Input<Def>,
                Operation.Definition.Output<Def>,
                E,
                Operation.Service | Services<Def>,
            >,
        ): (op: Def) => Operation.WithHandler<Def>;
        <Def extends Operation.Definition<any, any, any>, E = never>(
            op: Def,
            handler: Handler<
                Operation.Definition.Input<Def>,
                Operation.Definition.Output<Def>,
                E,
                Operation.Service | Services<Def>,
            >,
        ): Operation.WithHandler<Def>;
    } = ...

    Attaches a handler to an Operation definition. The handler may use any services declared in the operation, plus Operation.Service (always available). Dual API: can be called directly or used in a pipe.

    Type declaration

    const MyOp = Operation.make({
    input: Schema.Void,
    output: Schema.Void,
    meta: { key: 'my-op' },
    services: [DatabaseService],
    });

    // Direct call - handler can use DatabaseService
    const op = Operation.withHandler(MyOp, (input) =>
    Effect.gen(function* () {
    const db = yield* DatabaseService;
    return {};
    }),
    );

    // Piped call
    const op = MyOp.pipe(Operation.withHandler((input) => Effect.succeed({})));