Created
August 26, 2017 12:53
-
-
Save Deviad/3abd2488530a8a8d987948e3a42d417e to your computer and use it in GitHub Desktop.
Import the most needed parts of rxjs in ES6 Using prototype as using webpack it cannot do inference
properly on names that are used also by other libraries.
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 {Observable} from "rxjs/Observable"; | |
import "rxjs/observable/concat"; | |
import "rxjs/observable/from"; | |
import "rxjs/observable/of"; | |
import "rxjs/add/operator/map"; | |
import "rxjs/add/operator/mergeMap"; | |
import "rxjs/add/operator/startWith"; | |
import "rxjs/add/operator/filter"; | |
import "rxjs/add/operator/switchMap"; | |
import "rxjs/add/operator/catch"; | |
import "rxjs/add/operator/do"; | |
import "rxjs/add/observable/dom/ajax"; | |
import "rxjs/add/observable/combineLatest"; | |
import "rxjs/add/operator/debounceTime"; | |
Observable.prototype.concat$ = Observable.prototype.concat; | |
Observable.prototype.from$ = Observable.prototype.from; | |
Observable.prototype.of$ = Observable.prototype.of; | |
Observable.prototype.map$ = Observable.prototype.map; | |
Observable.prototype.mergeMap$ = Observable.prototype.mergeMap; | |
Observable.prototype.startWith$ = Observable.prototype.startWith; | |
Observable.prototype.filter$ = Observable.prototype.filter; | |
Observable.prototype.switchMap$ = Observable.prototype.switchMap; | |
Observable.prototype.catch$ = Observable.prototype.catch; | |
Observable.prototype.do$ = Observable.prototype.do; | |
Observable.ajax$ = Observable.ajax; | |
Observable.prototype.combineLatest$ = Observable.prototype.combineLatest; | |
Observable.prototype.debounceTime$ = Observable.prototype.debounceTime; | |
const debuggerOn = true; | |
Observable.prototype.debug = function (message) { | |
return this.do( | |
function (next) { | |
if (debuggerOn) { | |
console.log(message, next); | |
} | |
}, | |
function (err) { | |
if (debuggerOn) { | |
console.error("ERROR >>> ",message , err); | |
} | |
}, | |
function () { | |
if (debuggerOn) { | |
console.log("Completed."); | |
} | |
} | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment