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 onSubmit = function(title, description) { | |
// Do your ajax here | |
console.log(title, description); | |
}; | |
// Here we are opening up a lighbox to edit a title and description | |
// They will be the intial value of our component | |
flux.actions.widget.lightbox({ | |
view: ProfileContextEditCreate, | |
title: 'My awesome title', |
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
{ | |
"parser": "babel-eslint", | |
"env": { | |
"browser": true, | |
"es6": true, | |
"node": true | |
}, | |
"plugins": [ | |
"react" | |
], |
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
.then((details) => { | |
const newDetails = _.merge(details, { | |
creditLines: _.map(credit => { | |
if (!credit.creditTransaction) { return credit; } | |
const taxCredit = parseFloat(credit.creditTransaction.taxAmount, 10); | |
const tax = parseFloat(credit.originalTransaction.taxAmount, 10); | |
const lineTotal = parseFloat(credit.creditTransaction.lineTotal, 10); | |
return _.merge(credit, { |
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 React from 'react'; | |
import mouseTracker from 'decorators/mouseTracker'; | |
// options: { | |
// followMouse: false, | |
// positionOrder: ['top', 'bottom', 'left', 'right'], | |
// | |
// } | |
@mouseTracker |
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 R from 'ramda'; | |
function getValidators(ref) { | |
var propValidators = R.pathOr([], ['props', 'validators'], ref); | |
var refValidators = R.pathOr([], ['validators'], ref); | |
return [].concat(propValidators, refValidators); | |
} | |
function Tree(self, children) { | |
return { |
I wanted to take some time to talk about the humble map
function. If you have ever used libraries like underscore, lodash, or ramda, you are sure to encounter more than a few curious functions. The unassuming map
function is a good starting point on our journey to functional nirvana.
Taking a step back, what is map
? Just like normal maps (the paper kind!), map
is a guide to get from one place to another.
For example, in your notebook you have a list of numbers: 1 2 3
. Next to that list you write 2 3 4
. How did this happen? Simply enough, we went over each number in the list and added one to it. In other words, we mapped over the list of numbers and added one to them.
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 numbers = [1, 2, 3]; | |
var result = []; | |
for (var i = 0; i < numbers.length; i++) { | |
result.push(numbers[i] + 1); | |
} |
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 addOne(x) { | |
return x + 1; | |
} | |
var numbers = [1, 2, 3]; | |
var result = []; | |
for (var i = 0; i < numbers.length; i++) { | |
result.push(addOne(numbers[i])); | |
} |
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
[1, 2, 3].map(function(x) { | |
return x + 1; | |
}); |