Skip to content

Instantly share code, notes, and snippets.

View codecitizen's full-sized avatar

amp codecitizen

  • Alexander Partsch
  • Vienna, Austria
View GitHub Profile
@qwtel
qwtel / retry.js
Created March 18, 2017 15:36
Solid retry logic with rxjs5
// emits a value after `init` ms, then after `init * exp` ms, then `init * exp * exp` ms, etc.
function expInterval(init, exp) {
return Observable.create((observer) => {
let n = init;
let id;
function next() {
observer.next(n);
n *= exp;
id = setTimeout(next, n);