Created
April 17, 2019 03:05
-
-
Save brunoalano/fcb7b9d85adf170598b00540cf46cc0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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