createArrayBacked

static Event<TcreateArrayBacked<T>(Class<? extends Object> type, Function<Array<T>, T> invokerFactory)

Create an "array-backed" Event instance.

If your factory simply delegates to the listeners without adding custom behavior,consider using the other overload if performance of this event is critical.

Return

The Event instance.

Parameters

type

The listener class type.

invokerFactory

The invoker factory, combining multiple listeners into one instance.

<T>

The listener type.

static Event<TcreateArrayBacked<T>(Class<T> type, T emptyInvoker, Function<Array<T>, T> invokerFactory)

Create an "array-backed" Event instance with a custom empty invoker,for an event whose {@code invokerFactory} only delegates to the listeners.

  • If there is no listener, the custom empty invoker will be used.
  • If there is only one listener, that one will be used as the invokerand the factory will not be called.
  • Only when there are at least two listeners will the factory be used.

Having a custom empty invoker (of type (...) -> {}) increases performancerelative to iterating over an empty array; however, it only really mattersif the event is executed thousands of times a second.

Return

The Event instance.

Parameters

type

The listener class type.

emptyInvoker

The custom empty invoker.

invokerFactory

The invoker factory, combining multiple listeners into one instance.

<T>

The listener type.