Class: BlockSuggestor
Defined in: index.js:24
Class that tracks all blocks created in a workspace and suggests future blocks to use.
Properties index
| Property | Description |
|---|---|
| defaultJsonForBlockLookup | Saves the full JSON data for each block type the first time it's used. This helps store what initial configuration / sub-blocks each block type would be expected to have. |
| generateBlockData | Converts a list of block types to a full-fledge list of block data, limited to the specified size of the category |
| getMostUsed | Generates a list of the most frequently used blocks, in order. Includes a secondary sort by most recent blocks. |
| getRecentlyUsed | Generates a list of the most recently used blocks, in order, starting from the most recent. |
| numBlocksPerCategory | Config parameter which sets the size of the toolbox categories. |
| recentlyUsedBlocks | List of recently used block types in order, starting from the most recent |
| workspaceHasFinishedLoading | Checks if the workspace is finished loading, to avoid taking action on all the BLOCK_CREATE events during workspace loading. |
Methods index
| Method | Description |
|---|---|
| clearPriorBlockData | Resets the internal state of this object. |
| eventListener | Callback for when the workspace sends out events. |
| loadFromSerializedData | Loads the state of this object from a serialized JSON. |
| saveToSerializedData | Saves the state of this object to a serialized JSON. |
Constructors
Constructor
new BlockSuggestor(numBlocksPerCategory): BlockSuggestor;
Defined in: index.js:29
Constructs a BlockSuggestor object.
Parameters
| Parameter | Type | Description |
|---|---|---|
numBlocksPerCategory | number | the size of each toolbox category |
Returns
BlockSuggestor
Properties
defaultJsonForBlockLookup
defaultJsonForBlockLookup: object;
Defined in: index.js:35
Saves the full JSON data for each block type the first time it's used. This helps store what initial configuration / sub-blocks each block type would be expected to have.
generateBlockData
generateBlockData: (blockTypeList) => JSON[];
Defined in: index.js:53
Converts a list of block types to a full-fledge list of block data, limited to the specified size of the category
Parameters
| Parameter | Type | Description |
|---|---|---|
blockTypeList | string[] | the list of block types |
Returns
JSON[]
the block data list
getMostUsed
getMostUsed: () => BlockInfo[];
Defined in: index.js:51
Generates a list of the most frequently used blocks, in order. Includes a secondary sort by most recent blocks.
Returns
BlockInfo[]
A list of block JSON
getRecentlyUsed
getRecentlyUsed: () => object[];
Defined in: index.js:52
Generates a list of the most recently used blocks, in order, starting from the most recent.
Returns
object[]
A list of block JSON objects
numBlocksPerCategory
numBlocksPerCategory: number;
Defined in: index.js:48
Config parameter which sets the size of the toolbox categories.
recentlyUsedBlocks
recentlyUsedBlocks: any[];
Defined in: index.js:39
List of recently used block types in order, starting from the most recent
workspaceHasFinishedLoading
workspaceHasFinishedLoading: boolean;
Defined in: index.js:44
Checks if the workspace is finished loading, to avoid taking action on all the BLOCK_CREATE events during workspace loading.
Methods
clearPriorBlockData()
clearPriorBlockData(): void;
Defined in: index.js:150
Resets the internal state of this object.
Returns
void
eventListener()
eventListener(e): void;
Defined in: index.js:159
Callback for when the workspace sends out events.
Parameters
| Parameter | Type | Description |
|---|---|---|
e | Abstract | the event object |
Returns
void
loadFromSerializedData()
loadFromSerializedData(data): void;
Defined in: index.js:131
Loads the state of this object from a serialized JSON.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | object | the serialized data payload to load from |
Returns
void
saveToSerializedData()
saveToSerializedData(): object;
Defined in: index.js:140
Saves the state of this object to a serialized JSON.
Returns
object
a serialized data object including this object's state