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 1.0KB

12345678910111213141516171819202122232425262728
  1. /** PURE_IMPORTS_START _Observable,_scheduler_async,_util_isNumeric PURE_IMPORTS_END */
  2. import { Observable } from '../Observable';
  3. import { async } from '../scheduler/async';
  4. import { isNumeric } from '../util/isNumeric';
  5. export function interval(period, scheduler) {
  6. if (period === void 0) {
  7. period = 0;
  8. }
  9. if (scheduler === void 0) {
  10. scheduler = async;
  11. }
  12. if (!isNumeric(period) || period < 0) {
  13. period = 0;
  14. }
  15. if (!scheduler || typeof scheduler.schedule !== 'function') {
  16. scheduler = async;
  17. }
  18. return new Observable(function (subscriber) {
  19. subscriber.add(scheduler.schedule(dispatch, period, { subscriber: subscriber, counter: 0, period: period }));
  20. return subscriber;
  21. });
  22. }
  23. function dispatch(state) {
  24. var subscriber = state.subscriber, counter = state.counter, period = state.period;
  25. subscriber.next(counter);
  26. this.schedule({ subscriber: subscriber, counter: counter + 1, period: period }, period);
  27. }
  28. //# sourceMappingURL=interval.js.map