UNPKG

@blockly/block-shareable-procedures

Version:
103 lines 3.69 kB
/** * @license * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import * as Blockly from 'blockly/core'; /** Represents a procedure parameter. */ export declare class ObservableParameterModel implements Blockly.procedures.IParameterModel { private readonly workspace; private id; private variable; private shouldFireEvents; private procedureModel; /** * Constructor for the procedure parameter. * * @param workspace The workspace this parameter model exists in. * @param name The name of this parameter. * @param id The optional unique language-neutral ID of the parameter. * @param varId The optional ID of the variable this parameter should be * associated with. */ constructor(workspace: Blockly.Workspace, name: string, id?: string, varId?: string); /** * Sets the name of this parameter to the given name. * * @param name The string to set the name to. * @param id The optional ID the backing variable should have. * @returns This parameter model. */ setName(name: string, id?: string): this; /** * Creates a backing variable in a way that is subclassable. * * @param name The string to set set the variable to. * @param varId The optional ID the backing variable should have. * @returns The created variable model. */ protected createBackingVariable(name: string, varId?: string): Blockly.IVariableModel<Blockly.IVariableState>; /** * Unimplemented. The built-in ParameterModel does not support typing. * If you want your procedure blocks to have typed parameters, you need to * implement your own ParameterModel. * * @param types The types to set this parameter to. * @throws Throws for the ObservableParameterModel specifically because this * method is unimplemented. */ setTypes(types: string[]): this; /** * @returns the name of this parameter. */ getName(): string; /** * @returns the types of this parameter. */ getTypes(): string[]; /** * Returns the unique language-neutral ID for the parameter. This represents * the identity of the variable model which does not change over time. * * @returns The unique language-neutral ID for the parameter. */ getId(): string; /** * @returns the variable model associated with the parameter model. */ getVariableModel(): Blockly.IVariableModel<Blockly.IVariableState>; /** * Tells the parameter model it should fire events. * * @internal */ startPublishing(): void; /** * Tells the parameter model it should not fire events. * * @internal */ stopPublishing(): void; /** * Sets the procedure model this parameter is a part of. * * @param model The procedure model this parameter is a part of. * @returns This parameter model. */ setProcedureModel(model: Blockly.procedures.IProcedureModel): this; /** * Serializes the state of this parameter to JSON. * * @returns JSON serializable state of the parameter. */ saveState(): Blockly.serialization.procedures.ParameterState; /** * Returns a new parameter model with the given state. * * @param state The state of the parameter to load. * @param workspace The workspace to load the parameter into. * @returns The loaded parameter model. */ static loadState(state: Blockly.serialization.procedures.ParameterState, workspace: Blockly.Workspace): ObservableParameterModel; } //# sourceMappingURL=observable_parameter_model.d.ts.map