pub trait SchedulerExtensions {
// Required method
fn as_scheduler(&self) -> Rc<dyn IScheduler>;
// Provided methods
fn with_scheduler(&self) -> Rc<dyn IDisposable> { ... }
fn with<R>(&self, block: impl FnOnce(&Self) -> R) -> R { ... }
fn with_async<R: Clone + 'static>(
&self,
block: impl FnOnce(&Self) -> Task<R>,
) -> Task<R> ⓘ { ... }
}Expand description
Runs code with a scheduler as both schedulers of RxSchedulers, the main thread scheduler
and the task pool scheduler (SchedulerExtensions).
It is implemented for a scheduler handle (Rc<dyn IScheduler>, Rc<S>) and for the
TestScheduler of ferroui-reactive-testing; the block receives the scheduler it was called
on.
Deviation (DEVIATIONS.md, ReactiveUI): the schedulers of RxSchedulers are per thread, so the
scheduler is the scheduler of the current thread only.
Required Methods§
Sourcefn as_scheduler(&self) -> Rc<dyn IScheduler>
fn as_scheduler(&self) -> Rc<dyn IScheduler>
The scheduler as the handle that RxSchedulers holds.
Provided Methods§
Sourcefn with_scheduler(&self) -> Rc<dyn IDisposable>
fn with_scheduler(&self) -> Rc<dyn IDisposable>
Makes the scheduler both schedulers of RxSchedulers until the returned disposable is
disposed, which restores the schedulers set before (WithScheduler).
Sourcefn with<R>(&self, block: impl FnOnce(&Self) -> R) -> R
fn with<R>(&self, block: impl FnOnce(&Self) -> R) -> R
Runs block with the scheduler as both schedulers of RxSchedulers and returns its
result; the schedulers set before are restored afterwards, also when block panics
(With<TRet>(Func<T, TRet>), and With(Action<T>) with a block that returns ()).
Sourcefn with_async<R: Clone + 'static>(
&self,
block: impl FnOnce(&Self) -> Task<R>,
) -> Task<R> ⓘ
fn with_async<R: Clone + 'static>( &self, block: impl FnOnce(&Self) -> Task<R>, ) -> Task<R> ⓘ
Runs block with the scheduler as both schedulers of RxSchedulers until the task it
returns ends, and gives the outcome of that task (WithAsync<TRet>(Func<T, Task<TRet>>),
and WithAsync(Func<T, Task>) with a Task<()>).
A panic of block ends the returned task with the error of the panic
(PanicException), as an exception thrown in an async method faults its task; the
schedulers are restored in every case.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".