@itwin/presentation-frontend
Version:
Frontend of iModel.js Presentation library
142 lines • 5.18 kB
TypeScript
/** @packageDocumentation
* @module Core
*/
import { BeEvent, Id64String } from "@itwin/core-bentley";
import { RulesetVariable, VariableValue } from "@itwin/presentation-common";
import { IpcRequestsHandler } from "./IpcRequestsHandler.js";
/**
* Presentation ruleset variables' registry.
* @public
*/
export interface RulesetVariablesManager {
/**
* An event that is raised when variable changes.
*/
onVariableChanged: BeEvent<(variableId: string, prevValue: VariableValue | undefined, currValue: VariableValue | undefined) => void>;
/**
* Retrieves `string` variable value.
* Returns empty string if variable does not exist or does not convert to string.
*/
getString(variableId: string): Promise<string>;
/**
* Sets `string` variable value
*/
setString(variableId: string, value: string): Promise<void>;
/**
* Retrieves `boolean` variable value.
* Returns `false` if variable does not exist or does not convert to boolean.
*/
getBool(variableId: string): Promise<boolean>;
/**
* Sets `boolean` variable value
*/
setBool(variableId: string, value: boolean): Promise<void>;
/**
* Retrieves `number` variable value.
* Returns `0` if variable does not exist or does not convert to integer.
*/
getInt(variableId: string): Promise<number>;
/**
* Sets `number` variable value
*/
setInt(variableId: string, value: number): Promise<void>;
/**
* Retrieves `number[]` variable value.
* Returns empty array if variable does not exist or does not convert to integer array.
*/
getInts(variableId: string): Promise<number[]>;
/**
* Sets `number[]` variable value
*/
setInts(variableId: string, value: number[]): Promise<void>;
/**
* Retrieves `Id64String` variable value.
* Returns invalid Id64String if variable does not exist or does not convert to Id64String.
*/
getId64(variableId: string): Promise<Id64String>;
/**
* Sets `Id64String` variable value
*/
setId64(variableId: string, value: Id64String): Promise<void>;
/**
* Retrieves `Id64String[]` variable value.
* Returns empty array if variable does not exist or does not convert to Id64String array.
*/
getId64s(variableId: string): Promise<Id64String[]>;
/**
* Sets `Id64String[]` variable value
*/
setId64s(variableId: string, value: Id64String[]): Promise<void>;
/** Unsets variable with given id. */
unset(variableId: string): Promise<void>;
/** Retrieves all variables. */
getAllVariables(): RulesetVariable[];
}
/** @internal */
export declare class RulesetVariablesManagerImpl implements RulesetVariablesManager {
private _clientValues;
private _rulesetId;
private _ipcHandler?;
onVariableChanged: BeEvent<(variableId: string, prevValue: VariableValue | undefined, currValue: VariableValue | undefined) => void>;
constructor(rulesetId: string, ipcHandler?: IpcRequestsHandler);
getAllVariables(): RulesetVariable[];
private changeValueType;
private getValue;
private setValue;
unset(variableId: string): Promise<void>;
/**
* Retrieves `string` variable value.
* Returns empty string if variable does not exist or does not convert to string.
*/
getString(variableId: string): Promise<string>;
/**
* Sets `string` variable value
*/
setString(variableId: string, value: string): Promise<void>;
/**
* Retrieves `boolean` variable value.
* Returns `false` if variable does not exist or does not convert to boolean.
*/
getBool(variableId: string): Promise<boolean>;
/**
* Sets `boolean` variable value
*/
setBool(variableId: string, value: boolean): Promise<void>;
/**
* Retrieves `number` variable value.
* Returns `0` if variable does not exist or does not convert to integer.
*/
getInt(variableId: string): Promise<number>;
/**
* Sets `number` variable value
*/
setInt(variableId: string, value: number): Promise<void>;
/**
* Retrieves `number[]` variable value.
* Returns empty array if variable does not exist or does not convert to integer array.
*/
getInts(variableId: string): Promise<number[]>;
/**
* Sets `number[]` variable value
*/
setInts(variableId: string, value: number[]): Promise<void>;
/**
* Retrieves `Id64String` variable value.
* Returns invalid Id64String if variable does not exist or does not convert to Id64String.
*/
getId64(variableId: string): Promise<Id64String>;
/**
* Sets `Id64String` variable value
*/
setId64(variableId: string, value: Id64String): Promise<void>;
/**
* Retrieves `Id64String[]` variable value.
* Returns empty array if variable does not exist or does not convert to Id64String array.
*/
getId64s(variableId: string): Promise<Id64String[]>;
/**
* Sets `Id64String[]` variable value
*/
setId64s(variableId: string, value: Id64String[]): Promise<void>;
}
//# sourceMappingURL=RulesetVariablesManager.d.ts.map