jsketcher/web/app/cad/craft/wizard/wizardPlugin.js
2018-01-19 01:25:26 -08:00

26 lines
No EOL
639 B
JavaScript

import {createToken} from 'bus';
export function activate({bus, services}) {
bus.enableState(TOKENS.WIZARDS, []);
bus.subscribe(TOKENS.OPEN, ({type, initialState, overridingHistory}) => {
let wizard = {
type,
initialState,
overridingHistory,
};
bus.updateState(TOKENS.WIZARDS, opened => [...opened, wizard])
});
bus.subscribe(TOKENS.CLOSE, wizard => {
bus.updateState(TOKENS.WIZARDS, opened => opened.filter(w => w === wizard));
});
}
export const TOKENS = {
WIZARDS: createToken('wizards'),
OPEN: createToken('wizards', 'open'),
CLOSE: createToken('wizards', 'close'),
};