-
-
Save indexzero/1906920 to your computer and use it in GitHub Desktop.
THE FRAMEWORK YOUR FRAMEWORK COULD CODE LIKE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var flatiron = require('flatiron'), | |
app = flatiron.app; | |
console.log('What\'s that in your hand? Look down,'); | |
app.use(require('./tickets')); | |
console.log('look up. I HAVE IT. It\'s ' + app.qty + ' TICKETS to ' + app.description + '!'); | |
console.log('Look again.'); | |
app.use(require('./diamonds')); | |
console.log('THE TICKETS ARE NOW DIAMONDS'); | |
app.sparkle(); | |
setTimeout(function () { | |
app.stopSparkling(); | |
console.log('Anything is possible when you use flatiron and stop using express.'); | |
console.log('I\'m on a horse.'); | |
}, 6000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.attach = function () { | |
var sparkling = false; | |
this.sparkle = function sparkle () { | |
sparkling = true; | |
setTimeout(function () { | |
console.log('* bling *'); | |
if (sparkling) { | |
sparkle(); | |
} | |
}, 2000 * Math.random()); | |
}; | |
this.stopSparkling = function () { | |
sparkling = false; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22:18 josh@onix /tmp/old-spice | |
% node app.js | |
What's that in your hand? Look down, | |
look up. I HAVE IT. It's 2 TICKETS to that thing you love! | |
Look again. | |
THE TICKETS ARE NOW DIAMONDS | |
* bling * | |
* bling * | |
* bling * | |
* bling * | |
* bling * | |
* bling * | |
Anything is possible when you use flatiron and stop using express. | |
I'm on a horse. | |
* bling * | |
22:21 josh@onix /tmp/old-spice | |
% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.attach = function (opts) { | |
opts = opts || {}; | |
var that = this; | |
this.qty = opts.qty || 2; | |
this.description = opts.description || 'that thing you love'; | |
this.redeem = function () { | |
console.log('You go to see ' + that.description + ' and it\'s SPECTACULAR.'); | |
that.qty--; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment