Class WeakValue

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public final class WeakValue extends GObject
JSCWeakValue represents a weak reference to a value in a JSCContext. It can be used to keep a reference to a JavaScript value without protecting it from being garbage collected and without referencing the JSCContext either.
  • Constructor Details

    • WeakValue

      public WeakValue(MemorySegment address)
      Create a WeakValue instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • WeakValue

      public WeakValue(Value value)
      Create a new JSCWeakValue for the JavaScript value referenced by value.
      Parameters:
      value - a JSCValue
    • WeakValue

      public WeakValue()
      Create a new WeakValue.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the WeakValue class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected WeakValue asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • getValue

      public Value getValue()
      Get a JSCValue referencing the JavaScript value of weakValue.
      Returns:
      a new JSCValue or null if this WeakValue was cleared.
    • onCleared

      This signal is emitted when the JavaScript value is destroyed.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitCleared

      public void emitCleared()
      Emits the "cleared" signal. See onCleared(WeakValue.ClearedCallback).
    • builder

      public static WeakValue.Builder<? extends WeakValue.Builder> builder()
      A WeakValue.Builder object constructs a WeakValue with the specified properties. Use the various set...() methods to set properties, and finish construction with WeakValue.Builder.build().
      Returns:
      the builder object