Plugin reference
Plugin config.js settings
Config | type | Description |
---|---|---|
id | string | The plugin ID |
name | string | Shows when user selects a plugin |
description | string | Shows when user selects a plugin |
canBeInterrupted | boolean | True if you support interruption in your plugin |
canInterrupt | boolean | True if you want this plugin be used as interruption in other plugins |
canBeObserved | boolean | True if you support being observed by your interruptions |
canObserve | boolean | True if you support observing your parent plugins that you are interrupting |
storage | array | Config your fields as object with id and name where store in data in this plugin |
interruptionFields | array | add objects of fields with an id and a name of interruption data for this plugin |
Example:
const config = {
id: "multiple-choice",
name: "Multiple choice",
description: "Pick one of the options",
canBeInterrupted: false,
canInterrupt: true,
canBeObserved: false,
canObserve: true,
storage: [{ id: "video", name: "Video" }],
interruptionFields: [{ id: "timeInVideo", name: "Tijd in video" }],
}
export default config;
Plugin to be interrupted reference
canBeInterrupted
to true.- Set the
interruptionFields
in config. - Create
InterruptFormField.svelte
- Register the
InterruptFormField.svelte
in theplugin.js
- Access the interruptions in
Render.svelte
with:export let interruptions = []; for (let i = 0; i < interruptions.length; i++) { let interruption = interruptions[i]; if (interruption.data. ...) {
-
Dispatch interruption in
Render.svelte
:dispatch("interrupt", { interruption: interruption });
- Named slot
interruption
to display interruption inRender.svelte
.<slot name="interruption" />
- Create an advance function to continue with the plugin after an interruption in
Render.svelte
export function advance() {
Plugin to be observable reference
- Only plugins that can be interrupted can be observed.
canBeObservable
to true in the pluginconfig.js
- Provide a observe function in
Render.svelte
with:export function observe() {
- Dispatch
observeComplete
event when observing is done.dispatch("observeComplete");