Giter Site home page Giter Site logo

saiprashanths / react-dag Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ajainarayanan/react-dag

0.0 4.0 0.0 904 KB

This is a base implementation of wrapping jsplumb with react + redux to be more usable in a react based environment

License: MIT License

JavaScript 91.78% HTML 1.71% CSS 6.51%

react-dag's Introduction

react-dag

This is a base implementation of wrapping jsplumb with react + redux to be more usable in a react based environment.

Install

npm install git://github.com/ajainarayanan/react-dag.git#master

(As of now I have not yet published it to npm YET! Will do soon.)

Usage

  import {DAG} from 'react-dag';
  class MyComponent extends Component {
    ...
    render() {
      return (
        <DAG settings={this.settings}
            data={this.data}
            enhancers={this.enhancers}
            additionalReducersMap={this.additionalReducersMap}
            middlewares={this.middlewares}/>
      );
    }
  }

Props

  • settings - Settings to be used for JsPlumb. Check out dag-settings.js for base settings that are available.
Note
The `settings` prop is like either or - Either you provide the entire settings for the DAG or take the base settings. I am still yet to work on how to achieve granularity (or mixin) multiple different settings.
  • data - Is the initial state of the DAG. Could be used to render the DAG right away if the data is already available (instead of constructing the DAG one node at a time).

  • enhancers - Are the list of enhancers you would want to add to the dag-store. To read more about enhancers please check the documentation here

  • additionalReducersMap - The DAG comes with a base reducer that does some base operations. If you want additional reducers to be used for any property of the store you could pass in the map and the reducers would get reduce'd (as in executed one at a time. Something like reduce reducer)

    For instance the store right now has a structure like,

    {
      nodes: nodesReducer,
      connections: connectionsReducer,
      graph: graphReducer
    }
    

    In addition to the the nodesReducer if there are additional reducers that you want to add then it could be passed in as something like this,

    {
      nodes: [myReducer1, sometherReducer2]
    }
    

    Based on the additional reducer the above implementation of redux store's reducer becomes,

    {
      nodes: nodesReducers
              .reduce((prev, curr) => curr.bind(null, prev(state, action), action))(),
      connections: connectionsReducer
              .reduce((prev, curr) => curr.bind(null, prev(state, action), action))(),
      graph: graphReducer
              .reduce((prev, curr) => curr.bind(null, prev(state, action), action))(),
    }
    
    Note

    This is a little crude as of now. Will have to see if I can use this as a generic functionality for any store.

  • middlewares - Similar to additionalReducers you could pass in additional middlewares that you want to add based on your reducers.

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.