Skip to content

Instantly share code, notes, and snippets.

@zachgoll
Created September 12, 2020 02:48
Show Gist options
  • Save zachgoll/801c3f84557e3d4903863ec8cefafd19 to your computer and use it in GitHub Desktop.
Save zachgoll/801c3f84557e3d4903863ec8cefafd19 to your computer and use it in GitHub Desktop.
const { interval } = Rx;
const { map, take } = RxOperators;
// The input observable will emit the values 1, 2, 3
// in 1 second intervals
function inputObservable() {
const returnValues = [1, 2, 3];
return interval(1000)
.pipe(
take(returnValues.length),
map(val => returnValues[val])
);
}
// =====================================
// Don't worry about anything above this
//
// Just know that the input Observable
// returns the values 1, 2, 3
// =====================================
inputObservable().pipe(
take(2)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment