import { BaseExecutable } from "./BaseExecutable";
import { XDataDefinition } from "../Data/XDataDefinition";
export class AsyncExecutable extends BaseExecutable {
    set executionResult(res) {
        this._executionResult = res;
    }
    get executionResult() {
        return this._executionResult;
    }
    getExecutionResult() {
        if (!this.executionResult) {
            return this.executionResultCache || new XDataDefinition();
        }
        if (this.executionResult instanceof Function) {
            return this.executionResult();
        }
        else {
            return this.executionResult;
        }
    }
    get canChangeOutputs() {
        return !this.executionResult || !(this.executionResult instanceof Function);
    }
    getStorageData() {
        let data = super.getStorageData();
        Reflect.set(data, "executionResultCache", this.getExecutionResult().getStorageData());
        return data;
    }
    setStorageData(data) {
        super.setStorageData(data);
        let resultData = Reflect.get(data, "executionResultCache");
        if (resultData) {
            this.executionResultCache = new XDataDefinition();
            this.executionResultCache.setStorageData(resultData);
        }
    }
}
//# sourceMappingURL=AsyncExecutable.js.map