-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move backpack to use interface for backpackability (#2314)
* feat: move backpack to use interface for backpackability * chore: PR comments * fix: nits * chore: update README * chore: use version number
- Loading branch information
Showing
3 changed files
with
105 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
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,28 @@ | ||
/** | ||
* @license | ||
* Copyright 2024 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import * as Blockly from 'blockly/core'; | ||
|
||
/** Defines if an object can be added to the backpack. */ | ||
export interface Backpackable { | ||
/** | ||
* @return A representation of this object as a FlyoutItemInfo array, so that | ||
* it can be displayed in the backpack. | ||
* | ||
* This method should remove any unique or useless state data (e.g. IDs or | ||
* coordinates). | ||
*/ | ||
toFlyoutInfo(): Blockly.utils.toolbox.FlyoutItemInfo[]; | ||
} | ||
|
||
/** | ||
* @param obj The object we want to check is a Backpackable or not. | ||
* @return Whether the given object conforms to the Backpackable interface. | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export function isBackpackable(obj: any): obj is Backpackable { | ||
return obj.toFlyoutInfo !== undefined; | ||
} |