Skip to content

Instantly share code, notes, and snippets.

@griffinmichl
Created April 15, 2016 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save griffinmichl/a86ea64158ca8e61beac7515ce7ba022 to your computer and use it in GitHub Desktop.
Save griffinmichl/a86ea64158ca8e61beac7515ce7ba022 to your computer and use it in GitHub Desktop.
A saved Tricycle Program
"\nconst Cycle = require('@cycle/core');\nconst {makeDOMDriver, div, button} = require('@cycle/dom');\nconst _ = require('lodash');\nconst {Observable} = require('rx');\nconst {restartable} = require('cycle-restart');\n\nfunction main ({DOM}) {\n const add$ = DOM\n .select('.add')\n .events('click')\n .map(ev => 1);\n\n const count$ = add$\n .startWith(0)\n .scan((total, change) => total + change)\n\n return {\n DOM: count$.map(count =>\n div('.counter', [\n 'Count: ' + count,\n button('.add', 'Add')\n ])\n )\n };\n}\n\n// This looks a little different than normal. It's to enable support for cycle-restart,\n// which automatically plays back your actions when the code reloads.\n// See https://github.com/Widdershin/cycle-restart for more info\nconst sources = {\n DOM: restartable(makeDOMDriver('.app'), {pauseSinksWhileReplaying: false})\n}\n\n// Normally you need to call Cycle.run, but Tricycle handles that for you!\n// If you want to try this out locally, just uncomment this code.\n//\n// Cycle.run(main, sources);\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment