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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="[React Input Field]"> | |
<script src="http://code.jquery.com/jquery.min.js"></script> | |
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script> | |
<script src="http://fb.me/react-with-addons-0.12.2.js"></script> | |
<meta charset="utf-8"> |
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'; | |
//var React = require('react'); | |
import React from 'react'; | |
class App extends React.Component { | |
constructor() { | |
super(); | |
this.state = {online: false} |
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 Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 refreshButton = document.querySelector('.refresh'); | |
var closeButton1 = document.querySelector('.close1'); | |
var closeButton2 = document.querySelector('.close2'); | |
var closeButton3 = document.querySelector('.close3'); | |
var refreshClickStream = Rx.Observable.fromEvent(refreshButton, 'click'); | |
var close1Clicks = Rx.Observable.fromEvent(closeButton1, 'click'); | |
var close2Clicks = Rx.Observable.fromEvent(closeButton2, 'click'); | |
var close3Clicks = Rx.Observable.fromEvent(closeButton3, 'click'); |
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
/** | |
* @summary function that will flatten nested array into regular array | |
* @param Array - nested array (can be in different level) | |
*/ | |
const flatten = nestedArray => nestedArray.reduce( | |
(a, next) => a.concat(Array.isArray(next) ? flatten(next) : next), [] | |
); | |
// Test |
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 students = ['yoshie', 'hiroshie', 'lisa', 'johnny']; | |
students.splice(0,1); | |
console.log(students); | |
// ["hiroshie", "lisa", "johnny"] | |
// mutation, 不行啊~ |
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 students = ['yoshie', 'hiroshie', 'lisa', 'johnny']; | |
const removeStudent = (students, index) => { | |
return [ | |
...students.slice(0, index), | |
...students.slice(index + 1) | |
] | |
} | |
const addStudent = (students, index, newStudent) => { |
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 getStudentList = () => { | |
return new Promise((resolve, reject) => { | |
... | |
}); | |
} | |
const getStudentInfo = (id) => { | |
return new Promise((resolve, reject) => { | |
... | |
}) |
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* fetchStudentAddress() { | |
var studentList = yield getStudentList(); | |
var studentInfo = yield getStudentInfo(studentList[0].id); | |
} | |
function getAddress(callback) { | |
var getter = fetchStudentAddress(); | |
const go = (result) => { | |
if(result.done) return; // generator depleted |
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 testCase1 = () => { | |
// setup variables, conditions, and other funky junkie | |
someAsync().then((result) => { | |
// assign the result and process, it'll be used later for test conditions | |
}); | |
} |
OlderNewer