Skip to content

Instantly share code, notes, and snippets.

@nilshartmann
Created March 11, 2020 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilshartmann/e769c526b16bd1252de0e12f952c0e07 to your computer and use it in GitHub Desktop.
Save nilshartmann/e769c526b16bd1252de0e12f952c0e07 to your computer and use it in GitHub Desktop.
sprotty wrapper
class SprottyWrapper {
componentDidMount() {
// Diagramm erzeugen, wie in multicore.ts (hier stark gekürzt:)
this.processor = ...;
const modelSource = container.get<LocalModelSource>(TYPES.ModelSource);
modelSource.setModel(this.processor);
this.actionDispatcher = container.get<IActionDispatcher>(TYPES.IActionDispatcher);
}
componentDidUpdate() {
this.changeModel();
}
changeModel = () => {
// this.processor hier mit neuen Properties der Komponente (this.props) aktualisieren
for (let i = 0; i < this.processor.children!.length; ++i) {
const child = this.processor.children![i];
if (child.type === 'simplecore' && Math.random() > 0.7) {
(child as CoreSchema).kernelNr = Math.round(Math.random() * 11);
}
}
this.actionDispatcher.dispatch(new UpdateModelAction(this.processor));
}
render () {
return <div ><div>...</div></div>; // mit den benötigten Ids, siehe di.config.ts
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment