Built with blockbuilder.org
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
import React from 'react'; | |
import { render } from 'react-dom'; | |
import { Router } from 'react-router'; | |
import createBrowserHistory from 'history/lib/createBrowserHistory'; | |
import routes from './routes.js'; | |
const history = createBrowserHistory(); | |
// Setup google analytics tracking for react router transtions |
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
import ms from 'ms'; | |
import Rx from 'rxjs/Rx'; | |
const clicks$ = Rx.Observable.fromEvent(document.body, 'click'); | |
const createActionStream = () => Rx.Observable.merge( | |
Rx.Observable.of({ type: 'warning' }).delay(ms('14m')), | |
Rx.Observable.of({ type: 'logOut' }).delay(ms('15m')) | |
); |
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
// Just look the console output. | |
// NOTE: Requires Rx.js v5.x | |
var mousemoves$ = Rx.Observable.fromEvent(document.body, 'mousemove'); | |
// Events will be fired at most once every 200ms | |
var throtttled = mousemoves$.throttleTime(200); | |
// The latest event will be fired after 200ms. This means that if you are continually | |
// moving your mouse around the browser, causing mousemove events, none of them will |
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
license: gpl-3.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
const bleh = ['b', 'c', 'd']; | |
// Want arr === ['a', 'b', 'c', 'd'] | |
const arr = [ 'a', ...bleh ]; // ['a', 'b', 'c', 'd'] | |
// Also for objects | |
const basicInfo = { | |
name: 'Person', |
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
document.addEventListener('click', (e) => { | |
console.log(`The node that was clicked was ${e.target.toString()}`); | |
}); |
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
license: gpl-3.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
const ajax = (method, url, success) => { | |
// Create the new XHR | |
const xhr = new XMLHttpRequest(); | |
// "Open" the request. I.e. configure its method and request URL | |
xhr.open(method, url); | |
// Set up a success handler. For XHR we need to respond to changes in the readyState. However, | |
// the readyState can change for a number of reasons and we are only interested in the change | |
// that represents completion of the request. So we check whether readyState is equal to |
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
license: gpl-3.0 |