0.2.11 • Published 1 year ago
@volley/solid-scenes v0.2.11
@volley/solid-scenes
Scene binding and management support for skills using @volley/solid and @volley/solid-gev
Motivation
Scene classes and scene transitions need to be bound properly before a skill can run successfully.
Examples
Example usage in a sample skill
@sessionBinder()
export class SessionBinder extends Binder {
async bind(container: Container) {
container
.bind(ISkill)
.to(DiceGame)
.inSingletonScope()
container
.bind(BufferedInteractor)
.toSelf()
.inSingletonScope()
container
.bind(tokens.MermaidPath)
.toConstantValue("./src/skill/transitions.mmd")
await installSceneSupport(container)
}
}
By calling the provided installSceneSupport
:
- The
SceneBinder
is able to gather all the scene classes decorated with@scene
and bind them to the appropriate keys - The
MermaidBinder
is able to parse the mermaid file provided by the skill author and gather the scene transition information. Then, it can bind the transitions (transition key -> scene) (i.e. EntryScene.onEntryDone -> IntroScene)
export const installSceneSupport = async (container: Container) => {
const sceneBinder = new SceneBinder();
await sceneBinder.bind(container);
const mermaidBinder = new MermaidBinder();
await mermaidBinder.bind(container);
installTransitions(container);
}