# ObservableBase

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

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

```rust
struct ObservableBase<T>
```

An observable whose subscription is the user's [`ObservableCore`](/docs/0.5.0/api/ferroui-reactive/trait-observablecore/) (`ObservableBase<T>`).

The observer the core receives ignores everything after a terminal notification, and a
terminal notification, or a panic while the observer handles a value, disposes the
subscription (`AutoDetachObserver<T>`). When no work of the current-thread scheduler is
running, the subscription runs through its trampoline, so that work it schedules there runs
after the subscription has been set up.

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

## Members

- [`new`](#function-new)
- [`from_fn`](#function-from_fn)
- [`try_from_fn`](#function-try_from_fn)

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

### new

```rust
fn new(core: impl ObservableCore<T> + 'static) -> Self
```

An observable whose subscription is `core` (a subclass of `ObservableBase<T>` upstream).

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

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

### from_fn

```rust
fn from_fn(subscribe_core: impl Fn(Rc<dyn IObserver<T>>) -> Rc<dyn IDisposable> + 'static) -> Self
```

An observable whose subscription is the function `subscribe_core`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/observable_base.rs#L51)

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

### try_from_fn

```rust
fn try_from_fn(subscribe_core: impl Fn(Rc<dyn IObserver<T>>) -> Result<Rc<dyn IDisposable>, ObservableError> + 'static) -> Self
```

An observable whose subscription is the function `subscribe_core`, which may fail: an `Err`
is delivered to the observer as its error (a `SubscribeCore` that throws upstream).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/observable_base.rs#L59)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`SubscribeGuard<T>`](/docs/0.5.0/api/ferroui-base/reactive/use-subscribeguard/)
- [`IObservable<T>`](/docs/0.5.0/api/ferroui-base/reactive/use-iobservable/)

## Availability

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