Many of the core features of jasminewd are centered around automatically synchronizing your tests with the Web\+Driver control flow. However, jasminewd can synchronize with any scheduler as long as it implements the following interface\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{interface Scheduler \{}
\DoxyCodeLine{  execute<T>(fn: () => Promise<T>|T): Promise<T>;}
\DoxyCodeLine{\} }

\end{DoxyCode}


Where {\ttfamily execute} is the function used to put something on the scheduler. As long as your scheduler implements this interface, you can pass it into `require(\textquotesingle{}jasminewd2').init\`{}.\hypertarget{md_sfcode_node_modules_jasminewd2_scheduler_autotoc_md13947}{}\doxysection{Custom Promise Implementation}\label{md_sfcode_node_modules_jasminewd2_scheduler_autotoc_md13947}
Some schedulers need scheduled functions to use a specific implementation of the promise API. For instance, Web\+Driver has its {\ttfamily Managed\+Promise} implementation, which it needs in order to track tasks across {\ttfamily then()} blocks. If your scheduler has its own promise implementation, you can implement the following interface\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{interface SchedulerWithCustomPromises \{}
\DoxyCodeLine{  execute<T>(fn: () => CustomPromise<T>|T): CustomPromise<T>;}
\DoxyCodeLine{  promise<T>(resolver: (resolve: (T) => void, reject: (any) => void) => void): CustomPromise<T>;}
\DoxyCodeLine{\} }

\end{DoxyCode}


If the {\ttfamily promise} function is specified, jasminewd will use that function to generate all of its internal promises. If {\ttfamily scheduler.\+promise} is not specified, jasminewd will try to use Web\+Driver\textquotesingle{}s {\ttfamily Managed\+Promise}. If {\ttfamily Managed\+Promise} is not available (e.\+g. the control flow is disabled), jasminewd will default to using native promises.\hypertarget{md_sfcode_node_modules_jasminewd2_scheduler_autotoc_md13948}{}\doxysubsection{Idle API}\label{md_sfcode_node_modules_jasminewd2_scheduler_autotoc_md13948}
If your scheduler requires a custom promise implementation, it is highly recommended that you implement the Idle API. This will help to mitigate issues with users who sometimes use other promise implementations (see \href{https://github.com/angular/jasminewd/issues/68\#issuecomment-262317167}{\texttt{ https\+://github.\+com/angular/jasminewd/issues/68\#issuecomment-\/262317167}}). To do this, implement the following interface\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{var EventEmitter = require('events');}
\DoxyCodeLine{}
\DoxyCodeLine{interface SchedulerWithIdleAPI extends EventEmitter \{}
\DoxyCodeLine{  execute<T>(fn: () => CustomPromise<T>|T): CustomPromise<T>;}
\DoxyCodeLine{  promise<T>(resolver: (resolve: (T) => void, reject: (any) => void) => void): CustomPromise<T>;}
\DoxyCodeLine{  isIdle(): boolean;}
\DoxyCodeLine{\} }

\end{DoxyCode}


Your scheduler must emit {\ttfamily \char`\"{}idle\char`\"{}} when it becomes idle.\hypertarget{md_sfcode_node_modules_jasminewd2_scheduler_autotoc_md13949}{}\doxysubsection{Reset API}\label{md_sfcode_node_modules_jasminewd2_scheduler_autotoc_md13949}
If you want your scheduler to be reset whenever a spec times out, implement the following interface\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{interface SchedulerWithResetAPI \{}
\DoxyCodeLine{  execute<T>(fn: () => CustomPromise<T>|T): CustomPromise<T>;}
\DoxyCodeLine{  reset(): void;}
\DoxyCodeLine{\} }

\end{DoxyCode}


jasminewd will automatically look for a {\ttfamily reset} function and call it when specs time out. This is useful so that tasks from a timed out spec get cleared instead of continuing to tie up the scheduler and potentially getting executed during future specs. 