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
// classic component | |
class HelloMessage extends React.Component { | |
render() { | |
return <div>Hello {this.props.name}</div>; | |
} | |
} | |
// stateless component | |
const HelloMessage = (props) => { | |
return <div>Hello {props.name}</div>; | |
} |
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 Rx = require('rx'); | |
var Observable = Rx.Observable; | |
var Subject = Rx.Subject; | |
var hover = new Subject(); | |
var blur = new Subject(); | |
var hovers = hover.asObservable(); | |
var blurs = blur.asObservable(); | |
var HOVER_TIMER = 300; |
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 Rx = require('rx'); | |
var pauses = new Rx.Subject(); | |
var ends = new Rx.Subject(); | |
pauses. | |
flatMap(function () { | |
return Rx.Observable.amb( | |
Rx.Observable.timer(1000). | |
map(function () { return true }), | |
ends.map(function () { return false }) |
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 Rx = require('rx'); | |
var s1 = new Rx.Subject(); | |
var s2 = new Rx.Subject(); | |
var s3 = new Rx.Subject(); | |
Rx.Observable.merge(s1, s2, s3). | |
forEach( | |
console.log.bind(console, 'next'), | |
console.log.bind(console, 'error'), |
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 Rx = require('rx'); | |
var throwErrors = Rx.Observable.throw(new Error('tiny url exploded')); | |
throwErrors. | |
do( | |
function () {}, | |
function () { | |
console.log('handle error'); | |
} |
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 Rx = require('rx'); | |
var subjects = {}; | |
function create(sn) { | |
var s = new Rx.Subject(); | |
subjects[sn] = s; |
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 Rx = require('rx'); | |
var profileSwitchSuccess = new Rx.Subject(); | |
var cacheExpiryInHomeOnForeground = new Rx.Subject(); | |
var loginCheckDone = new Rx.Subject(); | |
profileSwitchSuccess.asObservable(). | |
map(function () { | |
return true; | |
}). |
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 Rx = require('rx'); | |
var profileSwitchSuccess = new Rx.Subject(); | |
var cacheExpiryInHomeOnForeground = new Rx.Subject(); | |
var loginCheckDone = new Rx.Subject(); | |
profileSwitchSuccess.asObservable(). | |
do(function () { | |
console.log('profile switch success'); | |
}). |