How to use the interval function from rxjs

Find comprehensive JavaScript rxjs.interval code examples handpicked from public code repositorys.

41
42
43
44
45
46
47
48
49
50
            ),
        maxRetries
    })

const monitor$ = taskId =>
    interval(MONITORING_FREQUENCY).pipe(
        exhaustMap(() => status$(taskId)),
        switchMap(({state, error_message: error}) =>
            (error || state === FAILED)
                ? throwError(() => new Error(error))
fork icon45
star icon178
watch icon34

-2
fork icon30
star icon10
watch icon2

+ 5 other calls in file

109
110
111
112
113
114
115
116
117
118
  },
  complete() {
    onComplete();
  },
};
this._latestSnapshotObservable = interval(this._options.snapshotInterval || 5000).pipe(
  switchMap(() => from(this.getLatestSnapshot())),
  multicast(new Subject()),
  refCount(),
);
fork icon7
star icon18
watch icon3

+ 7 other calls in file

13
14
15
16
17
18
19
20
21
22
} = require('rxjs/operators')
const { observer } = require('../utils')



// const event = interval(500).pipe(take(3),
const event = of('event').pipe(
  tap(() => console.log('[ side effect ]')),
  // share(),
  // publish(),
fork icon1
star icon8
watch icon2

+ 13 other calls in file

8
9
10
11
12
13
14
15
16
17
//  make Observable hot

const { interval } = require('rxjs');
const { share, take } = require('rxjs/operators');

const source$ = interval(100).pipe(take(3));

console.log('# without share');
source$.subscribe(v => console.log(`subscriber 1 received: ${v}`));
setTimeout(() => {
fork icon1
star icon0
watch icon0

+ 12 other calls in file

61
62
63
64
65
66
67
        
        return returnValue
    }
}

self._timeSignalSource = interval(1000).pipe(map(self._timeUpdate))
self.timeSignal = self._pauser.pipe(switchMap(paused => paused ? never() : self._timeSignalSource))
fork icon0
star icon2
watch icon4

52
53
54
55
56
57
58
59
60
61
exports.from = rxjs.from;
exports.fromEvent = rxjs.fromEvent;
exports.fromEventPattern = rxjs.fromEventPattern;
exports.generate = rxjs.generate;
exports.iif = rxjs.iif;
exports.interval = rxjs.interval;
exports.merge = rxjs.merge;
exports.never = rxjs.never;
exports.of = rxjs.of;
exports.onErrorResumeNext = rxjs.onErrorResumeNext;
fork icon299
star icon0
watch icon1

2
3
4
5
6
7
8
9
10
11
12
const {fileToJson$} = require('./file')
const {exec$} = require('./terminal')
const {basename} = require('path')


const monitorApps = () =>
    interval(5000).pipe(
        exhaustMap(() => apps$().pipe(
            concatMap(app => updateApp$(app).pipe(
                delay(5000)
            ))
fork icon45
star icon177
watch icon0

30
31
32
33
34
35
36
37
38
39
  this.emit('status', err)
}

listen() {
  return of(new PlexService(Config.payload.plex)).pipe(
    mergeMap((plex) => interval(5000).pipe(
      mergeMap(() => plex.status()),
      tap(status => this.state(status)),
      takeWhile(status => status === 'waiting', true),
      takeLast(1),
fork icon6
star icon98
watch icon6

16
17
18
19
20
21
22
23
24


// source stream -- an interval
// emitting at 50ms, 100ms, 150ms, 200ms, 250ms, etc
// we're taking 3 first values from it
const source$ = interval(50)
  .pipe(
    take(3)
  );
fork icon10
star icon159
watch icon3

22
23
24
25
26
27
28
29
30
31
}

reset() {
  const startDate = addHours(startOfDay(new Date()), this.startHour)
  const msUpdateFrequency = 100
  this.currentTime = interval(msUpdateFrequency).pipe(
    scan(
      (acc) =>
        addMilliseconds(
          acc,
fork icon1
star icon16
watch icon0

39
40
41
42
43
44
45
46
47
48
49
50
}


m2();


function m3() {
    const source = interval(500);
    const subject = new Subject();
    const refCounted = source.pipe(multicast(subject), refCount());
    let subscription1, subscription2;

fork icon1
star icon1
watch icon0

-3
fork icon1
star icon1
watch icon0

+ 2 other calls in file

0
1
2
3
4
5
6
7
8
9
10
11
12
const { Subject, interval } = require('rxjs');
const { takeUntil } = require('rxjs/operators');


const pageNavigationSubject$ = new Subject()


const observable$ = interval(100)


observable$.pipe(
    takeUntil(pageNavigationSubject$)
).subscribe(() => console.log('100ms have passed'))
fork icon1
star icon1
watch icon0

66
67
68
69
70
71
72
73
74
75

const once = action => system => of(0).pipe(map(() => action(system)))

const delayThen = (action, time=1) => system => timer(time).pipe(map(() => action(system)))

const repeatWithDelay = (action, time=1) => system => interval(time).pipe(map(() => action(system)))

const repeat = action => system => repeatWithDelay(action, 1)(system)

const fromPromise = action => system => from(action(system))
fork icon0
star icon1
watch icon7

+ 5 other calls in file

0
1
2
3
4
5
6
7
8
9
10
11
12
const { Subject, interval } = require('rxjs');
const { skipUntil } = require('rxjs/operators');


const pageNavigationSubject$ = new Subject()


const observable$ = interval(500)


observable$.pipe(
    skipUntil(pageNavigationSubject$)
).subscribe(console.log)
fork icon1
star icon0
watch icon0

42
43
44
45
46
47
48
49
50
51
52
    })
    return filteredObs$
}


var interval$ = fromInterval(500)
// var interval$ = interval(500)
// var evenNos$ = filterEven(interval$)
var evenNos$ = filter(interval$, x => x % 2 == 0)
const subscriber = evenNos$.subscribe(val => console.log(val))

fork icon1
star icon0
watch icon0

23
24
25
26
27
28
29
30
31
32

// eslint-disable-next-line no-unused-vars
return (stockSymbol, keywords = []) => {
    if (streams[stockSymbol]) return streams[stockSymbol];

    streams[stockSymbol] = interval(REQUESTS_INTERVAL).pipe(
        startWith(0), // starts immediately
        switchMap(() =>
            fromFetch(`${BASE_API_URL}/${stockSymbol}${HYPES_PATH}/last/50?token=${TOKEN}`)
                .pipe(switchMap(response => {
fork icon1
star icon0
watch icon1