-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a plugin example for creating custom types and fix grammar errors…
… in the documentation Signed-off-by: Axel Boberg <[email protected]>
- Loading branch information
1 parent
8f38a78
commit d3eb044
Showing
4 changed files
with
66 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Custom types example plugin | ||
This is an example plugin for showcasing how to create custom types that can be run within Bridge. | ||
The type definition is located within [package.json](./package.json) while the type-specific logic resides in [index.js](./index.js). |
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,29 @@ | ||
const bridge = require('bridge') | ||
|
||
/* | ||
The exported 'activate' function is the plugin's initialization function, | ||
it will be called when the plugin is loaded and every time a workspace | ||
is opened | ||
*/ | ||
exports.activate = async () => { | ||
/* | ||
Listen for the item.play event to react to an item being played, | ||
the item's type-property can be used to perform the correct action | ||
The type 'plugin-custom-types.my-type' is in this case | ||
defined within the plugin's package.json file | ||
*/ | ||
bridge.events.on('item.play', item => { | ||
if (item?.type === 'plugin-custom-types.my-type') { | ||
// Perform action | ||
console.log('MY CUSTOM TYPE PLAYED') | ||
} | ||
}) | ||
|
||
bridge.events.on('item.stop', item => { | ||
if (item?.type === 'plugin-custom-types.my-type') { | ||
// Perform action | ||
console.log('MY CUSTOM TYPE STOPPED') | ||
} | ||
}) | ||
} |
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,32 @@ | ||
{ | ||
"name": "plugin-custom-types", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"engines": { | ||
"bridge": "^0.0.1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"contributes": { | ||
"types": [ | ||
{ | ||
"id": "plugin-custom-types.my-type", | ||
"name": "My custom type", | ||
"inherits": "bridge.types.delayable", | ||
"category": "Custom types", | ||
"properties": { | ||
"myValue": { | ||
"name": "My custom value", | ||
"type": "string", | ||
"default": "Default value", | ||
"ui.group": "My custom type plugin" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} |