Skip to content

Instantly share code, notes, and snippets.

@brunoalano
Created April 17, 2019 03:05
Show Gist options
  • Save brunoalano/fcb7b9d85adf170598b00540cf46cc0f to your computer and use it in GitHub Desktop.
Save brunoalano/fcb7b9d85adf170598b00540cf46cc0f to your computer and use it in GitHub Desktop.
import * as React from 'react';
import { DiagramEngine, AbstractNodeFactory } from 'storm-react-diagrams';
import { BaseNodeModel } from '../models/BaseNodeModel';
import { BaseNodeWidget } from '../widgets/BaseNodeWidget';
export class AbstractActionNodeFactory<T extends BaseNodeModel, U extends BaseNodeWidget> extends AbstractNodeFactory<T> {
constructor(nodeType: string, public nodeModel: (new (...args: any[]) => T), public nodeWidget: (new (...args: any[]) => U)) {
super(nodeType);
}
generateReactWidget(diagramEngine: DiagramEngine, node: T): JSX.Element {
return React.createElement(this.nodeWidget, {
node: node,
diagramEngine: diagramEngine
});
}
getNewInstance(initialConfig?: any): T {
return new this.nodeModel();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment