# ContextDisposable

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactive/disposables/struct-contextdisposable/

**struct** · [`ferroui-reactive`](/docs/0.5.0/api/ferroui-reactive/) · v0.5.0

```rust
struct ContextDisposable
```

A disposable whose disposal is posted to a context, a `Schedule` (`ContextDisposable`).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/disposables/context_disposable.rs#L21)

## Members

- [`with_schedule`](#function-with_schedule)
- [`new`](#function-new)
- [`schedule`](#function-schedule)
- [`context`](#function-context)

<a id="function-with_schedule"></a>

### with_schedule

```rust
fn with_schedule(schedule: Arc<dyn Schedule>, disposable: Rc<dyn IDisposable>) -> Rc<Self>
```

Disposes `disposable` on `schedule` when it is disposed
(`ContextDisposable(SynchronizationContext, IDisposable)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/disposables/context_disposable.rs#L30)

<a id="function-new"></a>

### new

```rust
fn new(context: Arc<dyn SynchronizationContext>, disposable: Rc<dyn IDisposable>) -> Rc<Self>
```

Disposes `disposable` on `context` when it is disposed
(`ContextDisposable(SynchronizationContext, IDisposable)`).

> **Deprecated since 0.5.0.** use `ContextDisposable::with_schedule`

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/disposables/context_disposable.rs#L37)

<a id="function-schedule"></a>

### schedule

```rust
fn schedule(self: &Self) -> Option<&Arc<dyn Schedule>>
```

The schedule the disposal is posted to (`Context`), `None` for a deprecated context.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/disposables/context_disposable.rs#L46)

<a id="function-context"></a>

### context

```rust
fn context(self: &Self) -> &Arc<dyn SynchronizationContext>
```

The context the disposal is posted to (`Context`).
## Panics
When the disposable was made with a schedule (`with_schedule`).

> **Deprecated since 0.5.0.** use `ContextDisposable::schedule`

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/disposables/context_disposable.rs#L58)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`IDisposable`](/docs/0.5.0/api/ferroui-base/reactive/use-idisposable/)
- [`ICancelable`](/docs/0.5.0/api/ferroui-reactive/disposables/trait-icancelable/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
