Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AliSawari/2a2573ad443de0220b32a9ce2e6dba0e to your computer and use it in GitHub Desktop.
Save AliSawari/2a2573ad443de0220b32a9ce2e6dba0e to your computer and use it in GitHub Desktop.
RxJS iterate over an array by time
const keyInputs = [
['n', 1],
['e', 10],
['w', 100],
[' ', 1],
['y', 10],
['o', 100],
['r', 300],
['k', 200]
];
Rx.Observable.from(keyInputs)
.concatMap(([key, delayFor]) => Rx.Observable.of(key).delay(delayFor))
.subscribe(d => console.log(d));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment