This file contains 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
// Todo constants | |
module.exports = { | |
NEW_ITEM: 'NEW_ITEM', | |
SAVE_ITEM: 'SAVE_ITEM', | |
REMOVE_ITEM: 'REMOVE_ITEM' | |
}; |
This file contains 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
// Todo app dispatcher with actions responding to both | |
// view and server actions | |
var Dispatcher = require('flux').Dispatcher; | |
var AppDispatcher = new Dispatcher(); | |
AppDispatcher.handleViewAction = function(action) { | |
this.dispatch({ | |
source: 'VIEW_ACTION', | |
action: action |
This file contains 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
// Todo actions | |
var AppDispatcher = require('../dispatcher/AppDispatcher'); | |
var TodoConstants = require('../constants/TodoConstants'); | |
module.exports = { | |
addItem: function() { | |
AppDispatcher.handleViewAction({ | |
actionType: TodoConstants.NEW_ITEM | |
}); |
This file contains 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
// Todo store | |
// | |
// Requiring the Dispatcher, Constants, and | |
// event emitter dependencies | |
var AppDispatcher = require('../dispatcher/AppDispatcher'); | |
var AppConstants = require('../constants/TodoConstants'); | |
var ObjectAssign = require('object-assign'); | |
var EventEmitter = require('events').EventEmitter; | |
var CHANGE_EVENT = 'change'; |
This file contains 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> | |
<title>Todo App</title> | |
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"> |
This file contains 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
// React components | |
var React = require('react'); | |
var TodoStore = require('../stores/TodoStore'); | |
var TodoActions = require('../actions/TodoActions'); | |
var TodoItem = React.createClass({ | |
render: function() { | |
return( |
This file contains 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
// Todo constants | |
module.exports = { | |
NEW_ITEM: 'NEW_ITEM', | |
SAVE_ITEM: 'SAVE_ITEM', | |
REMOVE_ITEM: 'REMOVE_ITEM', | |
GET_RANDOM: 'GET_RANDOM', | |
GET_RANDOM_RESPONSE: 'GET_RANDOM_RESPONSE' | |
}; |
This file contains 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
// Todo server actions | |
var AppDispatcher = require('../dispatcher/AppDispatcher'); | |
var TodoConstants = require('../constants/TodoConstants'); | |
module.exports = { | |
receiveRandom: function(response) { | |
AppDispatcher.handleServerAction({ | |
actionType: TodoConstants.GET_RANDOM_RESPONSE, | |
response: response |
This file contains 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
// Todo actions | |
var AppDispatcher = require('../dispatcher/AppDispatcher'); | |
var TodoConstants = require('../constants/TodoConstants'); | |
var RandomUserAPI = require('../utils/RandomUserAPI'); | |
module.exports = { | |
addItem: function() { | |
AppDispatcher.handleViewAction({ | |
actionType: TodoConstants.NEW_ITEM |
This file contains 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
// Random User API logic | |
var TodoServerActions = require('../actions/TodoServerActions'); | |
var request = require('superagent'); | |
module.exports = { | |
get: function() { | |
request.get('http://api.randomuser.me/') | |
.set('Accept', 'application/json') | |
.end(function(err, response) { |
OlderNewer