# LightweightObservableBase

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

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

```rust
struct LightweightObservableBase<T>
```

The state of a lightweight observable: its observers, notified in
subscription order, and the error it failed with. Once it completes or
fails, the list is gone and later subscribers are told so at once.

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

## Members

- [`new`](#function-new)
- [`has_observers`](#function-has_observers)
- [`subscribe`](#function-subscribe)
- [`publish_next`](#function-publish_next)
- [`publish_completed`](#function-publish_completed)
- [`publish_error`](#function-publish_error)

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

### new

```rust
fn new() -> Self
```



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

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

### has_observers

```rust
fn has_observers(self: &Self) -> bool
```

Whether any observer is subscribed.

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

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

### subscribe

```rust
fn subscribe<O: LightweightObservable<T>>(owner: &Rc<O>, observer: Rc<dyn IObserver<T>>) -> Rc<dyn IDisposable>
where T: 'static
```

Subscribes `observer` to `owner`. The first subscription initializes
the owner; disposing the returned handle removes the observer.

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

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

### publish_next

```rust
fn publish_next(self: &Self, value: T)
where T: Clone
```

Notifies every observer of a value.

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

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

### publish_completed

```rust
fn publish_completed<O: LightweightObservable<T>>(owner: &O)
```

Completes the observable: notifies every observer and deinitializes
the owner.

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

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

### publish_error

```rust
fn publish_error<O: LightweightObservable<T>>(owner: &O, error: ObservableError)
```

Fails the observable: notifies every observer and deinitializes the
owner.

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

## 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`
- `Default`

## Availability

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