From 4486c1fa19f638379f339e77e97f271ef8aba15f Mon Sep 17 00:00:00 2001 From: Paul Taylor Date: Mon, 29 Feb 2016 16:09:51 -0800 Subject: [PATCH] feat(AsyncScheduler): add AsyncScheduler implementation --- src/Rx.DOM.ts | 3 +++ src/Rx.KitchenSink.ts | 3 +++ src/Rx.ts | 3 +++ src/scheduler/AsyncScheduler.ts | 10 ++++++++++ src/scheduler/async.ts | 3 +++ 5 files changed, 22 insertions(+) create mode 100644 src/scheduler/AsyncScheduler.ts create mode 100644 src/scheduler/async.ts diff --git a/src/Rx.DOM.ts b/src/Rx.DOM.ts index b56fb70330..fef7d595c6 100644 --- a/src/Rx.DOM.ts +++ b/src/Rx.DOM.ts @@ -124,9 +124,11 @@ import {EmptyError} from './util/EmptyError'; import {ArgumentOutOfRangeError} from './util/ArgumentOutOfRangeError'; import {ObjectUnsubscribedError} from './util/ObjectUnsubscribedError'; import {asap} from './scheduler/asap'; +import {async} from './scheduler/async'; import {queue} from './scheduler/queue'; import {animationFrame} from './scheduler/animationFrame'; import {AsapScheduler} from './scheduler/AsapScheduler'; +import {AsyncScheduler} from './scheduler/AsyncScheduler'; import {QueueScheduler} from './scheduler/QueueScheduler'; import {AnimationFrameScheduler} from './scheduler/AnimationFrameScheduler'; import {rxSubscriber} from './symbol/rxSubscriber'; @@ -136,6 +138,7 @@ import {AjaxRequest, AjaxResponse, AjaxError, AjaxTimeoutError} from './observab /* tslint:disable:no-var-keyword */ var Scheduler = { asap, + async, queue, animationFrame }; diff --git a/src/Rx.KitchenSink.ts b/src/Rx.KitchenSink.ts index ac418b397f..75c2eb09a9 100644 --- a/src/Rx.KitchenSink.ts +++ b/src/Rx.KitchenSink.ts @@ -172,8 +172,10 @@ import {EmptyError} from './util/EmptyError'; import {ObjectUnsubscribedError} from './util/ObjectUnsubscribedError'; import {ArgumentOutOfRangeError} from './util/ArgumentOutOfRangeError'; import {asap} from './scheduler/asap'; +import {async} from './scheduler/async'; import {queue} from './scheduler/queue'; import {AsapScheduler} from './scheduler/AsapScheduler'; +import {AsyncScheduler} from './scheduler/AsyncScheduler'; import {QueueScheduler} from './scheduler/QueueScheduler'; import {TimeInterval} from './operator/timeInterval'; import {TestScheduler} from './testing/TestScheduler'; @@ -184,6 +186,7 @@ import {rxSubscriber} from './symbol/rxSubscriber'; /* tslint:disable:no-var-keyword */ var Scheduler = { asap, + async, queue }; diff --git a/src/Rx.ts b/src/Rx.ts index 15ec5b5488..9b5edf2a9c 100644 --- a/src/Rx.ts +++ b/src/Rx.ts @@ -129,8 +129,10 @@ import {EmptyError} from './util/EmptyError'; import {ArgumentOutOfRangeError} from './util/ArgumentOutOfRangeError'; import {ObjectUnsubscribedError} from './util/ObjectUnsubscribedError'; import {asap} from './scheduler/asap'; +import {async} from './scheduler/async'; import {queue} from './scheduler/queue'; import {AsapScheduler} from './scheduler/AsapScheduler'; +import {AsyncScheduler} from './scheduler/AsyncScheduler'; import {QueueScheduler} from './scheduler/QueueScheduler'; import {rxSubscriber} from './symbol/rxSubscriber'; /* tslint:enable:no-unused-variable */ @@ -138,6 +140,7 @@ import {rxSubscriber} from './symbol/rxSubscriber'; /* tslint:disable:no-var-keyword */ var Scheduler = { asap, + async, queue }; diff --git a/src/scheduler/AsyncScheduler.ts b/src/scheduler/AsyncScheduler.ts new file mode 100644 index 0000000000..a92a2a01c9 --- /dev/null +++ b/src/scheduler/AsyncScheduler.ts @@ -0,0 +1,10 @@ +import {Action} from './Action'; +import {FutureAction} from './FutureAction'; +import {Subscription} from '../Subscription'; +import {QueueScheduler} from './QueueScheduler'; + +export class AsyncScheduler extends QueueScheduler { + scheduleNow(work: (x?: any) => Subscription, state?: any): Action { + return new FutureAction(this, work).schedule(state, 0); + } +} diff --git a/src/scheduler/async.ts b/src/scheduler/async.ts new file mode 100644 index 0000000000..fce4d75f68 --- /dev/null +++ b/src/scheduler/async.ts @@ -0,0 +1,3 @@ +import {AsyncScheduler} from './AsyncScheduler'; + +export const async = new AsyncScheduler();