Skip to content

Why not react? #1039

Open
Open
@mastir

Description

Hey! Thanks for this lib, i have used it in my project and its pretty good, but after some time i started asking myself "why?". And after few days i can not find answer.

  1. We create engine as global context for our elements, state machine, factories. And same do createContext in react.
  2. We use action based state machine for action processing and useReducer in react do absolutly the same and more.
  3. We use serialization to convert our elements into json representation and deserialization with factories to recreate and display our elements. And thats what react components do: take our data and render it.

So we can have something like:

let node = {
    x: 10,
    y: 10,
    ports: [
        {name: 'First port'},
        {name: 'Second port'},
    ]
}
return <Engine>
    <StateMachine>
        <DefaultState>
            <SelectingState />
        </DefaultSate>
        <DragNodeState />
        <CreateLinkState allowLooseLinks={false} />
    </StateMachine>
    <Canvas>
        <LinksLayer />
        <Node model={node}>
            <h1>Hello world!</h1>
           
            {node.ports.map( port =>  <div>
                <Port align={"left"} model={port}>
                    <div style={{background:'#00F',width:16,height:16,display:'inline-block'}}></div>
                </Port>
                {port.name}
            </div>)}
        </Node>
    </Canvas>

With absolutly same result, but simple

So is there any real reason not to do so?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions