Characteristic Locus
Inheritance object > FilterableChangeObserver<UNIT>
Implements IObserver<IChangeResult<UNIT>>
Inherited Members object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow
Assembly Meadow.Contracts.dll

Syntax

public class FilterableChangeObserver<UNIT> : IObserver<IChangeResult<UNIT>> where UNIT : struct

Type Parameters

Name Description
UNIT

The datatype that contains the notification data. I.e. Temperature or decimal. Must be a struct.

Constructors

FilterableChangeObserver(Action<IChangeResult<UNIT>>, Predicate<IChangeResult<UNIT>>?)

Creates a new FilterableChangeObserver that will execute the handler when a change occurs. If the filter parameter is supplied with a Predicate, only changes that satisfy that predicate (return true) will cause the handler to be invoked.

Declaration
public FilterableChangeObserver(Action<IChangeResult<UNIT>> handler, Predicate<IChangeResult<UNIT>>? filter = null)

Parameters

Type Name Description
Action<IChangeResult<UNIT>> handler

An Action that will be invoked when a change occurs.

Predicate<IChangeResult<UNIT>> filter

An optional Predicate that filters out any notifications that don't satisfy (return true) the predicate condition. Note that the first reading will always call the handler.

Fields

lastNotifiedValue

The last notified value. Note that this may differ from the Old property on the result, because this only gets updated if the filter is satisfied and the result is sent to the observer.

Declaration
protected UNIT? lastNotifiedValue

Field Value

Type Description
UNIT?

Properties

Filter

A filter that specifies whether or not the observer should get notified.

Declaration
protected Predicate<IChangeResult<UNIT>>? Filter { get; }

Property Value

Type Description
Predicate<IChangeResult<UNIT>>

Handler

Than handler that is called in OnNext if the filter is satisfied.

Declaration
protected Action<IChangeResult<UNIT>> Handler { get; }

Property Value

Type Description
Action<IChangeResult<UNIT>>

Methods

OnCompleted()

Notifies the observer that the provider has finished sending push-based notifications.

Declaration
public void OnCompleted()

OnError(Exception)

Notifies the observer that the provider has experienced an error condition.

Declaration
public void OnError(Exception error)

Parameters

Type Name Description
Exception error

An object that provides additional information about the error.

OnNext(IChangeResult<UNIT>)

Called by an Observable when a change occurs.

Declaration
public void OnNext(IChangeResult<UNIT> result)

Parameters

Type Name Description
IChangeResult<UNIT> result