# ConnectableObservableExt

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactive/linq/trait-connectableobservableext/

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

```rust
trait ConnectableObservableExt<T: 'static>
```

The operators of a connectable observable, as methods of its handle (the extension methods of
upstream's `Observable` on `IConnectableObservable<TSource>`: `RefCount`, `AutoConnect`).

The one required method gives the connectable observable as a handle; every operator is a
provided method, declared in the module of its family (`ref_count`, `auto_connect`). The trait
is implemented for `Rc<dyn IConnectableObservable<T>>`, which is also a handle of
`ObservableExt`, so the other operators apply to it as well.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/multicast.rs#L128)

## Members

- [`connectable`](#function-connectable)
- [`ref_count`](#function-ref_count)
- [`ref_count_min`](#function-ref_count_min)
- [`ref_count_with_delay`](#function-ref_count_with_delay)
- [`ref_count_with_delay_on`](#function-ref_count_with_delay_on)
- [`ref_count_min_with_delay`](#function-ref_count_min_with_delay)
- [`ref_count_min_with_delay_on`](#function-ref_count_min_with_delay_on)
- [`auto_connect`](#function-auto_connect)
- [`auto_connect_min`](#function-auto_connect_min)
- [`auto_connect_with`](#function-auto_connect_with)
- [`get_awaiter`](#function-get_awaiter)
- [`run_async`](#function-run_async)

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

### connectable

```rust
fn connectable(self: &Self) -> Rc<dyn IConnectableObservable<T>>
```

The connectable observable as the handle the operators take.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/multicast.rs#L130)

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

### ref_count

```rust
fn ref_count(self: &Self) -> std::rc::Rc<dyn ferroui_system::IObservable<T>>
```

A sequence that connects when it gets its first observer and disconnects when the last
one leaves (`RefCount()`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/multicast.rs#L132)

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

### ref_count_min

```rust
fn ref_count_min(self: &Self, min_observers: usize) -> std::rc::Rc<dyn ferroui_system::IObservable<T>>
```

`ref_count` that connects when it has `min_observers` observers
(`RefCount(int)`). Panics when `min_observers` is zero.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/multicast.rs#L132)

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

### ref_count_with_delay

```rust
fn ref_count_with_delay(self: &Self, disconnect_delay: std::time::Duration) -> std::rc::Rc<dyn ferroui_system::IObservable<T>>
```

`ref_count` that disconnects `disconnect_delay` after the last
observer leaves, unless an observer comes meanwhile, on the default scheduler
(`RefCount(TimeSpan)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/multicast.rs#L132)

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

### ref_count_with_delay_on

```rust
fn ref_count_with_delay_on(self: &Self, disconnect_delay: std::time::Duration, scheduler: std::rc::Rc<dyn crate::concurrency::IScheduler>) -> std::rc::Rc<dyn ferroui_system::IObservable<T>>
```

`ref_count_with_delay` on `scheduler`
(`RefCount(TimeSpan, IScheduler)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/multicast.rs#L132)

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

### ref_count_min_with_delay

```rust
fn ref_count_min_with_delay(self: &Self, min_observers: usize, disconnect_delay: std::time::Duration) -> std::rc::Rc<dyn ferroui_system::IObservable<T>>
```

`ref_count_with_delay` that connects when it has
`min_observers` observers (`RefCount(int, TimeSpan)`). Panics when `min_observers` is
zero.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/multicast.rs#L132)

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

### ref_count_min_with_delay_on

```rust
fn ref_count_min_with_delay_on(self: &Self, min_observers: usize, disconnect_delay: std::time::Duration, scheduler: std::rc::Rc<dyn crate::concurrency::IScheduler>) -> std::rc::Rc<dyn ferroui_system::IObservable<T>>
```

`ref_count_min_with_delay` on `scheduler`
(`RefCount(int, TimeSpan, IScheduler)`). Panics when `min_observers` is zero.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/multicast.rs#L132)

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

### auto_connect

```rust
fn auto_connect(self: &Self) -> std::rc::Rc<dyn ferroui_system::IObservable<T>>
```

A sequence that connects the source when it gets its first observer (`AutoConnect()`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/multicast.rs#L133)

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

### auto_connect_min

```rust
fn auto_connect_min(self: &Self, min_observers: usize) -> std::rc::Rc<dyn ferroui_system::IObservable<T>>
```

A sequence that connects the source when it has `min_observers` observers; zero connects
it at once (`AutoConnect(int)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/multicast.rs#L133)

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

### auto_connect_with

```rust
fn auto_connect_with(self: &Self, min_observers: usize, on_connect: impl FnOnce(std::rc::Rc<dyn ferroui_system::IDisposable>) -> () + 'static) -> std::rc::Rc<dyn ferroui_system::IObservable<T>>
```

`auto_connect_min` that hands the connection to `on_connect`,
with which the source can be disconnected (`AutoConnect(int, Action<IDisposable>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/multicast.rs#L133)

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

### get_awaiter

```rust
fn get_awaiter(self: Self) -> ferroui_system::task::Shared<Result<T, ferroui_system::ObservableError>>
where Self: Sized,
      T: Clone
```

Subscribes to the sequence, connects it, and gives a task of its last value
(`GetAwaiter(IConnectableObservable<TSource>)`); see
`ObservableExt::get_awaiter`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/multicast.rs#L134)

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

### run_async

```rust
fn run_async(self: Self, token: ferroui_system::threading::CancellationToken) -> ferroui_system::task::Shared<Result<T, ferroui_system::ObservableError>>
where Self: Sized,
      T: Clone
```

`get_awaiter` that the cancellation of `token` cancels, disposing
the subscription and the connection; a token canceled already cancels the task without
subscribing or connecting (`RunAsync(IConnectableObservable<TSource>, CancellationToken)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/linq/multicast.rs#L134)

## Trait implementations

- [`ConnectableObservableExt<T>`](/docs/0.5.0/api/ferroui-reactive/linq/trait-connectableobservableext/)

## Availability

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