The basic question boils down to "Who should dictate if the alert is rendered?"
In this situation, what you return from your render method is always rendered to the screen. Let's start by making a hypothetical API
// Example use | |
// var arr = [1, 2, 3, 4, 5]; | |
// var len = arr.length; | |
// var item = arr[len.random()]; | |
Number.prototype.random = function(inc) { | |
var val = (inc) ? 1 : 0; | |
return Math.floor(Math.random() * (this.valueOf() + val)); | |
}; |
function commentCommand(cmd) { | |
cmd = cmd || 'cmd'; | |
var result = require('execSync') | |
.exec('grep -nr "// '+cmd+':" ./') | |
.stdout | |
.split('\n')[0]; | |
if (result !== '') { | |
var reg = new RegExp('// '+cmd+':(.+)', 'i'); | |
result = result.match(reg)[1]; | |
} |
// Import settings | |
var settings = require('./settings'); | |
// Setup IRC | |
var irc = require('irc'); | |
var bot = new irc.Client(settings.server, settings.botName, settings); | |
console.log( | |
settings.botName + ' connecting to ' + settings.server + settings.channels | |
); |
// To play around with this code, copy and paste the contents of this gist | |
// into the javascript pane of http://jsbin.com/umoK/1/edit or go to | |
// http://jsbin.com/uZAfIqA/2/edit | |
// ============================================================================= | |
// Generic API | |
// ============================================================================= | |
//+ words :: string -> array | |
var words = split(' '); |
browserify: { | |
options: { | |
debug: true, | |
transform: ['reactify'], | |
extensions: ['.jsx'] | |
}, | |
dist: { | |
files: { 'app/public/scripts/scripts.js': 'app/src/scripts/main.js'} | |
} | |
} |
var IfElse = React.createClass({ | |
render: function() { | |
var contents = (something) ? <span>Hello</span> : <div>World!</div>; | |
return ( | |
<div> | |
{contents} | |
</div> | |
); | |
} |
var http = require('http'); | |
http.createServer(function(req, res) { | |
res.setTimeout(0) | |
setTimeout(function() { | |
res.writeHead(200, {'Content-Type': 'text/html'}); | |
res.write('<p>Hello World</p>'); | |
res.end(); | |
}, 100) |
" ============================================================================== | |
" Install Bundles | |
" ============================================================================== | |
" Required for neocomplcache | |
set nocompatible | |
filetype off | |
set rtp+=~/.vim/bundle/vundle | |
call vundle#rc() | |
" Installed Bundles | |
Bundle 'editorconfig/editorconfig-vim' |
'use strict'; | |
var React = require('react'); | |
var _ = require('ramda'); | |
var moment = require('moment'); | |
var Day = require('components/day'); | |
var Calendar = require('components/calendar'); | |
class MultiCalendar extends React.Component { |