# SingleSubscriberObservableBase

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

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

```rust
struct SingleSubscriberObservableBase<T>
```

The base of observables that accept exactly one subscriber and hand
themselves out as the subscription.

The observable embeds this state, implements `IObservable` by calling
`subscribe` and `IDisposable` by calling
`dispose`, passing what has to happen when the
subscription starts and ends.

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

## Members

- [`new`](#function-new)
- [`subscribe`](#function-subscribe)
- [`dispose`](#function-dispose)
- [`has_observer`](#function-has_observer)
- [`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/single_subscriber_observable_base.rs#L25)

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

### subscribe

```rust
fn subscribe(self: &Self, observer: Rc<dyn IObserver<T>>, subscribed: impl FnOnce() -> ())
```

Registers the observer. `subscribed` runs once it is registered,
unless the observable has already failed or completed, in which case
the observer is told so instead.

Panics when there already is a subscriber.

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

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

### dispose

```rust
fn dispose(self: &Self, unsubscribed: impl FnOnce() -> ())
```

Ends the subscription: runs `unsubscribed` and forgets the observer.

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

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

### has_observer

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

Whether an observer is currently subscribed.

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

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

### publish_next

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



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

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

### publish_completed

```rust
fn publish_completed(self: &Self, unsubscribed: impl FnOnce() -> ())
```



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

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

### publish_error

```rust
fn publish_error(self: &Self, error: ObservableError, unsubscribed: impl FnOnce() -> ())
```



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

## 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/).
