-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: trigger updates to IProcedureBlock blocks (#6570)
* feat: add interface and method for updating procedure blocks * chore: remove module ID declarations * feat: add actually triggering updates * chore: format * chore: clean up tests
- Loading branch information
Showing
6 changed files
with
60 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* @license | ||
* Copyright 2022 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import type {Block} from '../block.js'; | ||
|
||
|
||
/** The interface for a block which models a procedure. */ | ||
export interface IProcedureBlock { | ||
doProcedureUpdate(): void; | ||
} | ||
|
||
/** A type guard which checks if the given block is a procedure block. */ | ||
export function isProcedureBlock(block: Block| | ||
IProcedureBlock): block is IProcedureBlock { | ||
return (block as IProcedureBlock).doProcedureUpdate !== undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @license | ||
* Copyright 2022 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import {isProcedureBlock} from '../interfaces/i_procedure_block.js'; | ||
import {Workspace} from '../workspace.js'; | ||
|
||
|
||
/** | ||
* Calls the `doProcedureUpdate` method on all blocks which implement it. | ||
* | ||
* @internal | ||
*/ | ||
export function triggerProceduresUpdate(workspace: Workspace) { | ||
for (const block of workspace.getAllBlocks(false)) { | ||
if (isProcedureBlock(block)) { | ||
block.doProcedureUpdate(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters