Interface Lifecycled.Events<T>

All Known Implementing Classes:
LifecycledCallbackHandler
Enclosing interface:
Lifecycled<T>

public static interface Lifecycled.Events<T>
  • Method Summary

    Modifier and Type
    Method
    Description
    <O> void
    onInvalidated(O owner, BiConsumer<O,? super Lifecycled<T>> callback)
    Add a callback for when this lifecycled is invalidated.
    <O> void
    onNewValue(O owner, BiConsumer<O,? super Lifecycled<T>> callback)
    Add a callback for when this lifecycled is given a new value.
  • Method Details

    • onNewValue

      <O> void onNewValue(O owner, BiConsumer<O,? super Lifecycled<T>> callback)
      Add a callback for when this lifecycled is given a new value. Will be called immediately if this lifecycled is currently valid.

      The callback should not reference the owner, it must only access it via the parameter. This ensures that the owner will be GC-able, otherwise it may be stuck in a reference loop.

      Parameters:
      owner - when the owner is GC'd, the callback is removed
      callback - the callback, will be passed the lifecycled object
    • onInvalidated

      <O> void onInvalidated(O owner, BiConsumer<O,? super Lifecycled<T>> callback)
      Add a callback for when this lifecycled is invalidated. Will be called immediately if this lifecycled is currently invalid.

      The callback should not reference the owner, it must only access it via the parameter. This ensures that the owner will be GC-able, otherwise it may be stuck in a reference loop.

      Parameters:
      owner - when the owner is GC'd, the callback is removed
      callback - the callback, will be passed the lifecycled object