-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
flowGraphUnaryOperationBlock.ts
31 lines (28 loc) · 1.23 KB
/
flowGraphUnaryOperationBlock.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import type { FlowGraphDataConnection } from "../../flowGraphDataConnection";
import type { IFlowGraphBlockConfiguration } from "../../flowGraphBlock";
import type { RichType } from "../../flowGraphRichTypes";
import type { FlowGraphContext } from "../../flowGraphContext";
import { FlowGraphCachedOperationBlock } from "./flowGraphCachedOperationBlock";
/**
* @experimental
* The base block for all unary operation blocks. Receives an input of type InputT, and outputs a value of type ResultT.
*/
export class FlowGraphUnaryOperationBlock<InputT, ResultT> extends FlowGraphCachedOperationBlock<ResultT> {
input: FlowGraphDataConnection<InputT>;
constructor(
inputRichType: RichType<InputT>,
resultRichType: RichType<ResultT>,
private _operation: (input: InputT) => ResultT,
private _className: string,
config?: IFlowGraphBlockConfiguration
) {
super(resultRichType, config);
this.input = this._registerDataInput("input", inputRichType);
}
public override _doOperation(context: FlowGraphContext): ResultT {
return this._operation(this.input.getValue(context));
}
public getClassName(): string {
return this._className;
}
}