Need help with draw-cycle?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

bahmutov
135 Stars 5 Forks 21 Commits 1 Opened issues

Description

Simple Cycle.js application visualized: streams, events, DOM

Services available

!
?

Need anything else?

Contributors list

# 104,263
anime 37.5K JavaScript top 10
# 3,464
json-server 50.9K React top 10

draw-cycle

Simple Cycle.js application visualized: streams, events, DOM

Try yourself at glebbahmutov.com/draw-cycle

demo.gif

Full video in original resolution at https://youtu.be/-5-xyhd5fbQ

Simple Cycle.js taken from "Explicit dataflow" section at http://cycle.js.org/ - here is the application's code

function main(sources) {
  const decrement$ = sources.DOM
    .select('.decrement').events('click').map(ev => -1);

const increment$ = sources.DOM .select('.increment').events('click').map(ev => +1);

const action$ = Observable.merge(decrement$, increment$); const count$ = action$.startWith(0).scan((x,y) => x+y);

const vtree$ = count$.map(count => div([ button('.decrement', 'Decrement'), button('.increment', 'Increment'), p('Counter: ' + count) ]) ); return { DOM: vtree$ }; }

Visualization drawn using Raphael.js

Small print

Author: Gleb Bahmutov © 2016

License: MIT - do anything with the code, but don't blame me if it does not work.

Spread the word: tweet, star on github, etc.

Support: if you find any problems with this module, email / tweet / open issue on Github

MIT License

Copyright (c) 2016 Gleb Bahmutov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.