Search Results for

    Show / Hide Table of Contents

    Class Observable<T>

    Encapsulor that observes a value. 👀

    Inheritance
    object
    Observable<T>
    Namespace: GGL.Observer
    Assembly: GGL.dll
    Syntax
    public class Observable<T>
    Type Parameters
    Name Description
    T

    Class or basic type.

    Constructors

    | Edit this page View Source

    Observable()

    Create an observable variable with no default value.

    Declaration
    public Observable()
    | Edit this page View Source

    Observable(T)

    Create an observable variable with a default value.

    Declaration
    public Observable(T value)
    Parameters
    Type Name Description
    T value

    Base default value

    Properties

    | Edit this page View Source

    HasValue

    Declaration
    public bool HasValue { get; }
    Property Value
    Type Description
    bool

    Is there a value set?

    Remarks

    Useful for basic types like integers...

    | Edit this page View Source

    Value

    Declaration
    public T Value { get; set; }
    Property Value
    Type Description
    T

    Sets the value and eventually raise event OnChange.

    Methods

    | Edit this page View Source

    Clear()

    Clear value and raise event OnChange.

    Declaration
    public void Clear()
    | Edit this page View Source

    Commit()

    Raise event OnChange.

    Declaration
    public void Commit()
    Remarks

    The old value in the event will be the same as the new one...

    | Edit this page View Source

    Set(T, bool)

    Sets the value and eventually raise event OnChange.

    Declaration
    public void Set(T value, bool triggerEvent = true)
    Parameters
    Type Name Description
    T value

    New value.

    bool triggerEvent

    Well... if you want to sneakily set a value, set this to false.

    Events

    | Edit this page View Source

    OnChange

    Declaration
    public event Action<T, T> OnChange
    Event Type
    Type Description
    Action<T, T>

    Even raised after changes. Define a listener as follow:

    Operators

    | Edit this page View Source

    implicit operator bool(Observable<T>)

    Declaration
    public static implicit operator bool(Observable<T> current)
    Parameters
    Type Name Description
    Observable<T> current Encapsulor that observes a value. 👀
    Returns
    Type Description
    bool Encapsulor that observes a value. 👀
    | Edit this page View Source

    implicit operator T(Observable<T>)

    Declaration
    public static implicit operator T(Observable<T> current)
    Parameters
    Type Name Description
    Observable<T> current Encapsulor that observes a value. 👀
    Returns
    Type Description
    T Encapsulor that observes a value. 👀
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX