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
/* | |
* This is a version of Facebook's React Conditional Rendering | |
* example modified to support firebase authentication. | |
* https://facebook.github.io/react/docs/conditional-rendering.html | |
*/ | |
import React, { Component, PropTypes } from 'react'; | |
import * as firebase from 'firebase'; | |
function UserAvatar(props) { |
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
function test1() { | |
const timer = (ms) => { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
resolve(); | |
}, ms) | |
}); | |
} | |
let promises = [timer(4000), timer(2000), timer(3000), timer(1000)]; |
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
var promise1 = new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log('Begin resolve promise 1') | |
resolve('First') | |
console.log('End resolve promise 1') | |
}, 4000) | |
}) | |
var promise2 = new Promise((resolve, reject) => { | |
setTimeout(() => { |
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
const fetch = require('node-fetch') | |
const Bacon = require('baconjs') | |
function getInPortuguese(word) { | |
// Google Translate API is a paid (but dirt cheap) service. This is my key | |
// and will be disabled by the time the video is out. To generate your own, | |
// go here: https://cloud.google.com/translate/v2/getting_started | |
const apiKey = | |
'AIzaSyB4DyRHIsNhogQXmH16YKbZfR-lTXrQpq0' | |
const url = |
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
var timer = (ms) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(); | |
}, ms) | |
}); | |
} | |
promises = [timer(3000), timer(5000), timer(1000), timer(2000)] | |
async function doSomething() { |
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
var timer = (ms) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(); | |
}, ms) | |
}); | |
} | |
promises = [timer(3000), timer(5000), timer(1000), timer(2000)] | |
async function doSomething() { | |
idx = 0; |
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
var test = () => { | |
new Promise((resolve, reject) => { | |
resolve(undefined); // Will call then | |
}).then(() => { | |
console.log("Then"); | |
}).catch(() => { | |
console.log("Catch"); | |
}) | |
} |
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
var timer = (ms) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(); | |
}, ms) | |
}); | |
} | |
var promise1 = timer(4000); | |
timer(4000).then(() => { |
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
var timer = (ms) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(); | |
}, ms) | |
}); | |
} | |
promises = [timer(3000), timer(5000), timer(1000), timer(2000)] | |
promises.reduce((chain, promise, idx) => { |
NewerOlder