Coder Social home page Coder Social logo

Comments (6)

mwozniczak avatar mwozniczak commented on May 7, 2024 8

My $0.02, since I've been called in:

Basically, what's core to understanding the lib (and feel free to correct me @dylanvorster, I'm still kinda learning it :D) is this:

  1. If you're familiar with MVC, it's kind of like that, with all the Widget classes being the View layer and Models are, sliiightly contrary to their name, something in-between actual Models and Controllers, depending on how you want to play it. @dylanvorster seems particularly keen on giving you the freedom to make the call which of the two do you want them to be.
  2. DiagramEngine is the main thing running the show, with its DiagramModel (which is baked in, you can access it via getDiagramModel() or just substitute your own. This is where you'll add factories that are what binds models and widgets together.
  3. Factories, by default work like this: your node models (nodels, if you will?) each have a nodeType (which is a string). DiagramModel uses that type to pick which factory to use. Then, when you add a new node to the model, it's gonna use the factory's generateReactWidget method to actually deliver the widget. Do note, so as not to make my mistake, that multiple nodels can have the same type, with the logic dedicated to deciding which widget to pick might be delegated elsewhere: to the factory, or where have you.
  4. Don't sweat factories too much. Just get a good base going (e.g. by taking my advice above and not making too many specialized ones), and the majority of work you'll be doing with the lib will be in nodels and widgets anyway.

Apologies if the above is too ranting and chaotic, I've scarcely had any sleep last night :D

Anyway, if you have any questions, don't hesitate to ask them, @gen4sp (or anyone i suppose) :)

from react-diagrams.

dylanvorster avatar dylanvorster commented on May 7, 2024 2

the best way to learn how to create your own nodes is to take a look at the default folder. I do plan to make guides and docs, I just don't have too much time at the moment. But more to the point: the best way would be to create your own NodeModel (like MyNewNodeModel extends NodeModel) and then to register a WidgetFactory that knows how to render that type. I will provide a 'demo3' folder now that shows how to create custom nodes and models. In the mean time, please check out https://github.com/mwozniczak/adventure-weave by @mwozniczak who has been pushing me for quite a few of these things (thanks @mwozniczak for all the support thus far :) ). I am also willing to help on bitter if you need some assistance :)

from react-diagrams.

dylanvorster avatar dylanvorster commented on May 7, 2024

I just added a demo3 folder which shows a more complex example on how to really extend this library as intended, it created a diamond node, that has 4 inputs at each corner.

from react-diagrams.

gen4sp avatar gen4sp commented on May 7, 2024

Awesome, thanks!

from react-diagrams.

dylanvorster avatar dylanvorster commented on May 7, 2024

I kind of one to pin this until I can get some guides going o_o

from react-diagrams.

mwozniczak avatar mwozniczak commented on May 7, 2024

Well, by all means :D

from react-diagrams.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.