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 someCollection = [{ | |
results: [ | |
{ | |
name: 'alpha', | |
region : { | |
region_id : 1234 | |
} | |
}, | |
{ | |
name: 'beta', |
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
/* | |
* create data STREAM | |
* using RX observable timer which allows a starts with time plus interval vs, | |
* flatMapLatest will always merge the last value from stream, | |
* so we don't create multiple observers which are hanging in limbo | |
* give me the first observable that satisfies our predicate, which then unsubscribes OR | |
* unsubscribe after elapsed time of 1 minute | |
*/ | |
function pollData(dataMart) { | |
return Rx.Observable.timer(2000, 15000) |
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
// watch angular scope $destroy expression and create a kill observable | |
var controllerScopeIsDestroyed = angularObservableSvc.watchToObservable($scope, '$destroy'); | |
// get datamart status request | |
var statusObs = dataMartSvc.getSavedState({ | |
userId: $stateParams.id, | |
refId: $stateParams.ref | |
}); | |
// get custom views request |
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 getWikipediaSearchResults(term) { | |
return Rx.Observable.create(function forEach(observer) { | |
var cancelled = false; | |
var url = 'http://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=' | |
+ encodeURIComponent(term) + '&callback=?'; | |
$.getJSON(url, function(data) { | |
if (!cancelled) { | |
observer.onNext(data[1]); | |
observer.onCompleted(); | |
} |
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> | |
<link rel="stylesheet" href="style.css"> | |
<script src="https://code.jquery.com/jquery-2.1.3.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/rxjs/2.3.25/rx.all.js"></script> | |
<script src="script.js"></script> | |
</head> |