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
// Old way | |
import { from } from 'rxjs/observable/from'; | |
const source$ = from([1, 2, 3, 4, 5, 6, 7, 8, 9]); | |
source$ | |
.filter(x => x % 2) | |
.map(x => x * 2) | |
.scan((acc, next) => acc + next, 0) | |
.startWith(0) |
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 url = "https://api.example.com/autocomplete" | |
let controller; | |
let signal; | |
autocompleteInput.addEventListener('keyup', () => { | |
if (controller !== undefined) { | |
// Cancel the previous request | |
controller.abort(); | |
} |
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
config.entry = { | |
app: [ | |
path.resolve(__dirname, `../app/client/client.jsx`), | |
], | |
polyfills: [ | |
`babel-polyfill`, | |
`whatwg-fetch`, | |
], | |
}; |
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
swPrecache.write(path.resolve(__dirname, `../public/service-worker.js`), { | |
cacheId: `know-it-all`, | |
filename: `service-worker.js`, | |
stripPrefix: `public/`, | |
staticFileGlobs: [ | |
`public/app.*.js`, // don't include the polyfills version | |
`public/*.{html,ico,json,png}`, | |
], | |
dontCacheBustUrlsMatching: [ | |
/\.(js|json)$/, // I'm cache busting js and json files myself |
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 HTMLChanger = (function() { | |
var contents = 'contents' | |
var changeHTML = function() { | |
var element = document.getElementById('attribute-to-change'); | |
element.innerHTML = contents; | |
} | |
return { | |
callChangeHTML: function() { |
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 Exposer = (function() { | |
var privateVariable = 10; | |
var privateMethod = function() { | |
console.log('Inside a private method!'); | |
privateVariable++; | |
} | |
var methodToExpose = function() { | |
console.log('This is a method I want to expose!'); |
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 TeslaModelS = function() { | |
this.numWheels = 4; | |
this.manufacturer = 'Tesla'; | |
this.make = 'Model S'; | |
} | |
TeslaModelS.prototype.go = function() { | |
// Rotate wheels | |
} |
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 TeslaModelS = function() { | |
this.numWheels = 4; | |
this.manufacturer = 'Tesla'; | |
this.make = 'Model S'; | |
} | |
TeslaModelS.prototype = function() { | |
var go = function() { | |
// Rotate wheels | |
}; |
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 Subject = function() { | |
this.observers = []; | |
return { | |
subscribeObserver: function(observer) { | |
this.observers.push(observer); | |
}, | |
unsubscribeObserver: function(observer) { | |
var index = this.observers.indexOf(observer); | |
if(index > -1) { |
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
// Implementation |