Skip to content

Instantly share code, notes, and snippets.

View amysimmons's full-sized avatar

Amy Simmons amysimmons

View GitHub Profile
// define the generator function 
function *foo(x) {
	var y = x * (yield);
	return y;
}

// create the iterable to control the generator and pass in 6
var it = foo(6);
var x = 1

// define a generator 
function *foo() {
	x++;
	yield; // pause
	console.log("x: ", x);
}
const p1 = Promise.resolve('twenty-two');
const p2 = Promise.resolve(22);
const p3 = Promise.reject('Doh');

Promise.race([p1, p2, p3])
  .then(function fulfilled(value) {
    console.log(value);
  })
// twenty-two 
// p1 and p2 are the same

const p1 = new Promise(function(resolve, reject) {
  reject('Oh no');
});

const p2 = Promise.reject('Oh no');

// p3 and p4 are the same
const p = new Promise(function(resolve, reject){
  // resolve(...) to go to the fulfilled or rejected handler, depending on what is passed
  // reject(...) to go to the rejected handler 
});
var p1 = new Promise((resolve, reject) => {
  // throw Error('Something went wrong in the promise')
  resolve(42);
});

p1.then(
  (value) => {
    // throw Error('Something went wrong in the handler')
 console.log(value)
// A
setTimeout( function () {
  // C
}, 1000);
// B

Using JavaScript frameworks at scale in TweetDeck

Resources for a talk I'm giving at a [Women Who Code London meetup][11], April 2018.

  • [FlightJS][4]
  • [FlightJS in 2016 - a blog post by Tom Ashworth][6]
  • [How we use Twitter Flight in TweetDeck - a blog post by Tom Ashworth (2014)][5]
  • [RxJS in TweetDeck - a presentation by Amy Simmons and Guillaume Marty][0]
  • [RxJS documentation][1]
  • [You Don't Know JS - a book series by Kyle Simpson][2]
  • [JSJabber podcast][3]
{"a": 42} // SyntaxError: Unexpected token ':'. Parse error.

function foo (data) { 
  console.log(data.a) 
}

foo({"a":42}) // 42
false == "0" // true
// false gets coerced to 0
// "0" gets coerced to 0
// 0 == 0 is true 

false == 0 // true
// false gets coerced to 0
// 0 == 0 is true