Table of Contents

ObservableAction<T> Struct

public readonly struct ObservableAction<T> : IObservableAction<T>, IObservable<T>, IDisposable, IEquatable<ObservableAction<T>>

Type Parameters

T
Implements
Inherited Members
Extension Methods

Constructors

ObservableAction(Action<Action<T>>, Action<Action<T>>)

Create IObservable<T> with sub (+=) and unsub (-=)

public ObservableAction<T> MyEvent => new(x => _backingEventField += x, x => _backingEventField -= x);

// adding `event` to backing field will make it thread-safe (not only for preventing access from externals)
event Action<T>? _backingEventField;

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Equals(ObservableAction<T>)

Indicates whether the current object is equal to another object of the same type.

Equals(object?)

Indicates whether this instance and a specified object are equal.

GetHashCode()

Returns the hash code for this instance.

Subscribe(Action<T>, bool)
Unsubscribe(Action<T>)

Operators

operator ==(in ObservableAction<T>, in ObservableAction<T>)
operator !=(in ObservableAction<T>, in ObservableAction<T>)

Explicit Interface Implementations

IObservableAction<T>.Subscribe(Action<T>, bool)
IObservable<T>.Subscribe(IObserver<T>)

Notifies the provider that an observer is to receive notifications.