RxJS Playground

A blank canvas to play / experiment with RxJS: https://github.com/Reactive-Extensions/RxJS

by adil_invideo

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/4.0.7/rx.all.js"></script>

JavaScript

console.clear();
/* 
var array = ["a", "d", "c"];

var o1 = Rx.Observable.from(array); // 'a, d, c
o1.subscribe(x => console.log('fromarray:', x));

function fakeApiCall(value) {
  var lookupValues = { "a": 123, "b": 234, "c": 345, "d": 456 };
  return Rx.Observable.just({ id: value, lookup: lookupValues[value] });
}

var o2 = o1.flatMap(x => {
  // here we return an observable using the values in o1
  // which could be an api call returning a value
  return fakeApiCall(x);
});

o2.subscribe(x => console.log('flatmap result:', x)); */


const subject = new Rx.Subject<number>();
console.log(subject);
subject.asObservable().subscribe(it => console.log("GOT ", it));

subject.next(1);