fix: feedback on procedure model implementations (#6560)

* fix: feedback on procedure model implementations

* chore: format
This commit is contained in:
Beka Westberg
2022-10-25 08:46:42 -07:00
committed by GitHub
parent a46e12b06b
commit 41db0c5fb0
2 changed files with 11 additions and 7 deletions

View File

@@ -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;
}
/**

View File

@@ -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);
}
}