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.
		
		
		
		
			
				
					21 lines
				
				758 B
			
		
		
			
		
	
	
					21 lines
				
				758 B
			| 
											5 years ago
										 | import { Observable } from '../Observable'; | ||
|  | import { async } from '../scheduler/async'; | ||
|  | import { isNumeric } from '../util/isNumeric'; | ||
|  | export function interval(period = 0, scheduler = async) { | ||
|  |     if (!isNumeric(period) || period < 0) { | ||
|  |         period = 0; | ||
|  |     } | ||
|  |     if (!scheduler || typeof scheduler.schedule !== 'function') { | ||
|  |         scheduler = async; | ||
|  |     } | ||
|  |     return new Observable(subscriber => { | ||
|  |         subscriber.add(scheduler.schedule(dispatch, period, { subscriber, counter: 0, period })); | ||
|  |         return subscriber; | ||
|  |     }); | ||
|  | } | ||
|  | function dispatch(state) { | ||
|  |     const { subscriber, counter, period } = state; | ||
|  |     subscriber.next(counter); | ||
|  |     this.schedule({ subscriber, counter: counter + 1, period }, period); | ||
|  | } | ||
|  | //# sourceMappingURL=interval.js.map
 |