Coder Social home page Coder Social logo

dreno's Introduction

what?

dreno (portuguese for drain) is a small framework that combines the functional-reactive approach of Cycle.js with the simplicity and scalability of state management given by MobX.

why?

Because it had to be done. Read more about it here.

how does it work?

Basically, you render some components with React while accessing values from a state that is given by the observable function. Whenever the components emit events you want to react to, you track these events. Any tracked event can be accessed from the select function as a xstream stream. From the streams given by select and any other streams you may create (for example, for accessing external or browser APIs) you should be able to deduce the values that will then be passed to observable.

See some simple live examples with the code used to generate them.

getting started

npm install dreno

You may start your app by copypasting the following boilerplate:

// app.js

const ReactDOM = require('react-dom')
const {observer, observable, track, select} = require('dreno')

const state = observable({
  /* attributes that will be accessed
   * directly from the components
   * go here.
   *
   * count: select('a.add-one')
   *   .events('click')
   *   .mapTo(1)
   *   .fold((acc, s) => acc + s, 0)
   *   .startWith(0)
   */
})

const MainComponent = observer(
  /* any React component class, either a stateless function,
   * a class inheriting from React.Component or created with
   * 'create-react-class'.
   *
   * only remember to set the event handlers to `track`,
   * like <a href='#' className='add-one' onClick={track}>click here to add 1</a>
   */
)

ReactDOM.render(
  MainComponent,
  document.getElementById(/* your react root element */)
)

Apart from that, you can do all the usual React stuff, transpilation etc.


Some germans performing drainage:

picture of some germans performing drainage

based on an idea first exposed at https://gist.github.com/fiatjaf/ece86e33b1f8846c8f8c318778b0895a.

dreno's People

Contributors

fiatjaf avatar

Watchers

 avatar  avatar  avatar

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.