# Observable

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/reactive/struct-observable/

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

```rust
struct Observable
```

Factory functions for observables.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/reactive/observable.rs#L8)

## Members

- [`create`](#function-create)
- [`return_`](#function-return_)
- [`single_value`](#function-single_value)
- [`never`](#function-never)
- [`empty`](#function-empty)
- [`switch`](#function-switch)
- [`combine_latest_all`](#function-combine_latest_all)
- [`from_event_pattern`](#function-from_event_pattern)

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

### create

```rust
fn create<T: 'static>(subscribe: impl Fn(Rc<dyn IObserver<T>>) -> Rc<dyn IDisposable> + 'static) -> Rc<dyn IObservable<T>>
```

Creates an observable from a subscribe function.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/reactive/observable.rs#L26)

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

### return_

```rust
fn return_<T: Clone + 'static>(value: T) -> Rc<dyn IObservable<T>>
```

An observable that produces a single value and completes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/reactive/observable.rs#L33)

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

### single_value

```rust
fn single_value<T: Clone + 'static>(value: T) -> Rc<dyn IObservable<T>>
```

An observable that produces a single value and never completes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/reactive/observable.rs#L42)

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

### never

```rust
fn never<T: 'static>() -> Rc<dyn IObservable<T>>
```

An observable that never produces a value.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/reactive/observable.rs#L50)

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

### empty

```rust
fn empty<T: 'static>() -> Rc<dyn IObservable<T>>
```

An observable that completes immediately.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/reactive/observable.rs#L55)

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

### switch

```rust
fn switch<TSource: 'static>(sources: Rc<dyn IObservable<Rc<dyn IObservable<TSource>>>>) -> Rc<dyn IObservable<TSource>>
```

Forwards the values of the most recent of the observables that
`sources` produces.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/reactive/observable.rs#L64)

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

### combine_latest_all

```rust
fn combine_latest_all<TInput: Clone + 'static>(inputs: impl IntoIterator<Item = Rc<dyn IObservable<TInput>>>) -> Rc<dyn IObservable<Vec<TInput>>>
```

Combines the latest values of a sequence of observables: once every
one of them has produced a value, each new value produces the list of
the latest ones.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/reactive/observable.rs#L73)

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

### from_event_pattern

```rust
fn from_event_pattern<T: Clone + 'static>(add_handler: impl Fn(Rc<dyn Fn(&T) -> ()>) -> Rc<dyn IDisposable> + 'static) -> Rc<dyn IObservable<T>>
```

An observable of the arguments of an event.

`add_handler` adds the handler it is given to the event and returns
the handle that removes it, as the events of this crate do (the
original takes one function to add and one to remove a handler, for
events with and without typed arguments).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/reactive/observable.rs#L85)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`

## Availability

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