Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

interval.js 758B

123456789101112131415161718192021
  1. import { Observable } from '../Observable';
  2. import { async } from '../scheduler/async';
  3. import { isNumeric } from '../util/isNumeric';
  4. export function interval(period = 0, scheduler = async) {
  5. if (!isNumeric(period) || period < 0) {
  6. period = 0;
  7. }
  8. if (!scheduler || typeof scheduler.schedule !== 'function') {
  9. scheduler = async;
  10. }
  11. return new Observable(subscriber => {
  12. subscriber.add(scheduler.schedule(dispatch, period, { subscriber, counter: 0, period }));
  13. return subscriber;
  14. });
  15. }
  16. function dispatch(state) {
  17. const { subscriber, counter, period } = state;
  18. subscriber.next(counter);
  19. this.schedule({ subscriber, counter: counter + 1, period }, period);
  20. }
  21. //# sourceMappingURL=interval.js.map