Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@erichosick
Last active August 29, 2015 14:08
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 erichosick/d036582d9b9b28a11e01 to your computer and use it in GitHub Desktop.
Save erichosick/d036582d9b9b28a11e01 to your computer and use it in GitHub Desktop.
Gist of stuff done in youtube video here: http://youtu.be/3gSiYtBEMjY
First Setup (command Line):
mkdir mech
cd mech
npm install mech-core
npm install mech-scope-cell
npm install mech-math
npm install mech-emit
node
Within node:
var m = require('./node_modules/mech-core/dist/mech-core');
var sp = require('./node_modules/mech-scope-cell/dist/mech-scope-cell');
var math = require('./node_modules/mech-math/dist/mech-math');
var emit = require('./node_modules/mech-emit/dist/mech-emit');
// define two cells
sp.cell("A:1", 45); // Cell A:1 contains 45
sp.cell("A:2", 23); // Cell A:2 contains 23
sp.cellGet("A:2").go; // Just return 23
sp.cell("A:3", math.add(sp.cellGet("A:1"), sp.cellGet("A:2"))); // Define an add in cell A:3
sp.cellGet("A:3").go; // Run A:3 as numberic
sp.cellGet("A:3").goStr; // Run A:3 as a string
sp.cellSet("A:1",2).go; // Set cell A:1 to 2
sp.cellGet("A:3").goStr; // It's reactive. Notice Add is now 2 + 23
sp.cellWorkBook; // Yep! That is the entire program
sp.cell("A:5", emit.emitFromRange(1,2000,2,true)); // Define an emitter in cell A:5
sp.cellWorkBook["A:5"].go; // Run multiple times to see the cell emit.
sp.cell("A:7", math.add(sp.cellGet("A:5"), sp.cellGet("A:3"))); // Yep!
sp.cellGet("A:7").goStr; // Run multiple times to see it emit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment