mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
fix: feedback on procedure model implementations (#6560)
* fix: feedback on procedure model implementations * chore: format
This commit is contained in:
@@ -17,7 +17,8 @@ export class ObservableParameterModel implements IParameterModel {
|
||||
constructor(
|
||||
private readonly workspace: Workspace, name: string, id?: string) {
|
||||
this.id = id ?? genUid();
|
||||
this.variable = workspace.createVariable(name);
|
||||
this.variable =
|
||||
this.workspace.getVariable(name) ?? workspace.createVariable(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,12 +35,14 @@ export class ObservableParameterModel implements IParameterModel {
|
||||
* 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.
|
||||
*
|
||||
* @throws Throws for the ObservableParameterModel specifically because this
|
||||
* method is unimplemented.
|
||||
*/
|
||||
setTypes(_types: string[]): this {
|
||||
console.warn(
|
||||
throw new Error(
|
||||
'The built-in ParameterModel does not support typing. You need to ' +
|
||||
'implement your own custom ParameterModel.');
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ export class ObservableProcedureMap extends Map<string, IProcedureModel> {
|
||||
* Adds the given procedure model to the procedure map.
|
||||
*/
|
||||
override set(id: string, proc: IProcedureModel): this {
|
||||
// TODO(#6156): Fire events.
|
||||
// TODO(#6516): Fire events.
|
||||
super.set(id, proc);
|
||||
return this;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ export class ObservableProcedureMap extends Map<string, IProcedureModel> {
|
||||
* exists).
|
||||
*/
|
||||
override delete(id: string): boolean {
|
||||
// TODO(#6156): Fire events.
|
||||
// TODO(#6516): Fire events.
|
||||
return super.delete(id);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export class ObservableProcedureMap extends Map<string, IProcedureModel> {
|
||||
* Removes all ProcedureModels from the procedure map.
|
||||
*/
|
||||
override clear() {
|
||||
// TODO(#6156): Fire events.
|
||||
// TODO(#6516): Fire events.
|
||||
super.clear();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@ export class ObservableProcedureMap extends Map<string, IProcedureModel> {
|
||||
* blocks can find it.
|
||||
*/
|
||||
add(proc: IProcedureModel): this {
|
||||
// TODO(#6156): Fire events.
|
||||
// TODO(#6516): Fire events.
|
||||
// TODO(#6526): See if this method is actually useful.
|
||||
return this.set(proc.getId(), proc);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user