GgValue<T> class

Represents a value of Type T in the memory.

Implemented types
Implementers

Constructors

GgValue({required T seed, bool spam = false, bool compare(T a, T b)?, T transform(T)?, bool isOk(T)?, T parse(String)?, String stringify(T)?, String? name})
  • seed The initial seed of the value.
  • If spam is true, each change of the value will be added to the stream.
  • If spam is false, updates of the value are scheduled as micro tasks. New updates are not added until the last update has been delivered. Only the last set value will be delivered.
  • transform allows you to keep value in a given range or transform it.
  • parse is needed when T is not String, int, double or bool. It converts a string into T.
  • stringify is needed when T is not String, int, double or bool. It converts the value into a String.
  • name is an optional identifier for the value.
  • Properties

    changeStream Stream<GgChange<T>>
    no setter
    compare → (bool Function(T a, T b)?)
    Set a custom comparison operator
    final
    hashCode int
    The hashcode of a GgValue is calculated based on the value.
    no setteroverride
    isOk → (bool Function(T)?)
    Use that callback to perform some validation
    final
    isSynced bool
    no setter
    jsonDecodedValue ↔ dynamic
    Returns int, double and bool and string as they are.
    getter/setter pairoverride-getter
    name String?
    An optional name.
    final
    runtimeType Type
    A representation of the runtime type of the object.
    no setterinherited
    seed → T
    The default value
    no setteroverride
    spam bool
    Allows reducing the number of updates delivered when the value is changed multiple times.
    getter/setter pairoverride-getter
    stream → _GgValueStream<T>
    Returns a stream informing about changes on the value
    no setteroverride
    stringValue String
    Converts the value into a string value and returns the result.
    getter/setter pairoverride-getter
    syncStream → _GgValueStream<T>
    Returns a sync stream informing about changes on the value
    no setteroverride
    transform → (T Function(T)?)
    Is used to transform assigned values to other ones, e.g. to keep the value in a given range.
    final
    value ↔ T
    Returns the value
    getter/setter pairoverride-getter

    Methods

    dispose() → void
    Call this method when the value is about to be released.
    forceUpdate() → void
    Informs all listeners about a change.
    noSuchMethod(Invocation invocation) → dynamic
    Invoked when a nonexistent method or property is accessed.
    inherited
    reset() → void
    syncWith(GgValue<T> other) → void
    Two way sync this value with another value
    toString() String
    Returns a string representation of the GgValue.
    override
    unsync() → void
    Remove the synchronization with another element

    Operators

    operator ==(Object other) bool
    This operator compares to GgValue objects based on the value. When given, the compare function is used to make the comparison.
    override

    Static Methods

    isSimpleJsonValue(dynamic value) bool