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
import makeActionCreator from '../utils/makeActionCreator'; | |
export const ENTER_PAGE_REQUEST = 'ENTER_PAGE_REQUEST'; | |
export const enterPageRequest = makeActionCreator(ENTER_PAGE_REQUEST); | |
export const ENTER_PAGE_SUCCESS = 'ENTER_PAGE_SUCCESS'; | |
export const enterPageSuccess = makeActionCreator(ENTER_PAGE_SUCCESS); | |
export const ENTER_PAGE_ERROR = 'ENTER_PAGE_ERROR'; | |
export const enterPageError = makeActionCreator(ENTER_PAGE_ERROR); |
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
export const handlers { | |
[SHOW_ERROR_MODAL]: { | |
// only called after specific case is proven not to exists | |
// the specific cases will exists below like such | |
}, | |
/* RESET PASSWORD SPECIFIC STATE */ | |
[RESET_PASSWORD_INITIAL_STATE]: { | |
// props = props sent from container | |
}, |
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
const openRollFowardModal = makeActionCreator('OPEN'); | |
function openRollFowardModalAndFetchFiles() { | |
return dispatch => new Promise((resolve, reject) => { | |
dispatch(openRollFowardModal()); | |
disaptch(fetchFilesRequest()); | |
RollForwardAPI.fetchFiles() | |
.then(() => dispatch(fetchFilesSuccess()) | |
.catch(() => dispatch(fetchFilesError('It looks like there no files to roll forward.', error); | |
}); |
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
export function getUsers() { | |
return dispatch => ( | |
new Promise((resolve, reject) => { | |
dispatch(getUsersRequest()); | |
UsersAPI.getUsers() | |
.then((data) => { | |
dispatch(getUsersSuccess(data)); | |
resolve(data); | |
}) | |
.catch((err) => { |
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
/* | |
Routes | |
1) should do finds | |
2) should do saves/updates | |
3) should handle control flow | |
4) should name anonymous functions in control flow | |
5) should namespace routers {Namespace}Router | |
--> PublicRouter, AdminRouter... | |
6) should have all of the routes in a top level namespace | |
--> sample route /{namespace}/:id/{namespace_sub_resource} |
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
// callback | |
UserModel.find({}, function(err, results) { | |
if (err) throw err; | |
// do something with results | |
}); | |
// exec | |
var query = UserModel.find({}); | |
query.exec(function(err, results) { | |
if (err) throw err; |
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
// complex validation | |
UserSchema.pre('save', function(next) { | |
UserModel.find({ username: this.username }, function(err, user) { | |
if (!user) { | |
return next(); | |
} | |
return next(new Error('username already exist!')); | |
}); | |
}); |
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
'use strict'; | |
// intregration test | |
var app = require('../../server'); | |
var request = require('supertest'); | |
var should = require('should'); | |
var mongoose = require('mongoose'); | |
describe('review-note', function() { | |
describe('GET /review_notes', function() { |
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 data = ['a','b','c','d','e','f','g','h']; | |
var tree = {}; | |
function isEmpty(data) { return data.length === 0; } | |
function isRoot(tree) { return !Object.keys(tree).length; } | |
function isSubtree(tree) { return Object.keys(tree).length; } | |
var makeTree = function (data, tree) { | |
if (isEmpty(data)) return tree; |
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
function add(a,b) { | |
if (a === 0) { | |
return b; | |
} else { | |
return add(--a, ++b) | |
} | |
} | |
alert(add(1,2)) | |
alert(add(45,2)) |
NewerOlder