RAGS - v1.10.0
    Preparing search index...

    Class Binding<Emitter, Prop, Return>

    Represents a reactive binding between a GObject property and a consumer.

    Bindings track a source emitter and property, and can apply transform functions to map the source value before it reaches the consumer.

    const label = Widget.Label({
    label: battery.bind('percent').as(p => `${p}%`),
    });

    Type Parameters

    • Emitter extends GObject.Object

      The GObject type that emits property changes

    • Prop extends keyof Props<Emitter>

      The property key on the emitter

    • Return = Emitter[Prop]

      The transformed output type (defaults to the property type)

    Index

    Constructors

    Methods

    Properties

    Constructors

    Methods

    • Creates a new Binding with a transform function chained after any existing transforms.

      Type Parameters

      • T

      Parameters

      • fn: (v: Return) => T

        Transform function to apply to the bound value

      Returns Binding<Emitter, Prop, T>

      A new Binding with the transform applied

      const binding = service.bind('value')
      .transform(v => v * 2)
      .transform(v => `${v}px`);
    • The transform function applied to the raw property value.

      Parameters

      • v: any

      Returns any

    Properties

    emitter: Emitter

    The source GObject that emits property change notifications.

    prop: Prop

    The property name on the emitter being observed.