Package: grails.events

## [Groovy] Trait Events

- grails.events.Events

- A trait that can be applied to any class to enable event sending and receiving

  Authors:
    Graeme Rocher
  Since:
    3.0

- - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `reactor.bus.EventBus` | `eventBus`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `boolean` | `clearEventConsumers(java.lang.Object key)` Clears event consumers for the given key
    `reactor.bus.Event<T>` | `eventFor(T data)` Creates an reactor.bus.Event for the given data
    `reactor.bus.Event<T>` | `eventFor(java.util.Map<java.lang.String, java.lang.Object> headers, T data)` Creates an reactor.bus.Event for the given headers and data
    `reactor.bus.Event<T>` | `eventFor(java.util.Map<java.lang.String, java.lang.Object> headers, T data, groovy.lang.Closure<java.lang.Throwable> errorConsumer)` Creates an reactor.bus.Event for the given headers, data and error consumer
    `reactor.bus.Bus` | `notify(java.lang.Object key, reactor.bus.Event<?> ev)` @see reactor.bus.Bus#notify(java.lang.Object, java.lang.Object)
    `reactor.bus.Bus` | `notify(java.lang.Object key, java.lang.Object data)` @see reactor.bus.Bus#notify(java.lang.Object, reactor.bus.Event)
    `reactor.bus.Bus` | `notify(java.lang.Object key, groovy.lang.Closure<E> supplier)` @see reactor.bus.Bus#notify(java.lang.Object, reactor.bus.Event)
    `reactor.bus.registry.Registration<java.lang.Object, reactor.fn.Consumer<E>>` | `on(java.lang.Class key, groovy.lang.Closure consumer)` @see #on(reactor.bus.selector.Selector, reactor.fn.Consumer)
    `reactor.bus.registry.Registration<java.lang.Object, reactor.fn.Consumer<E>>` | `on(reactor.bus.selector.Selector key, groovy.lang.Closure consumer)` @see #on(reactor.bus.selector.Selector, reactor.fn.Consumer)
    `reactor.bus.registry.Registration<java.lang.Object, reactor.fn.Consumer<E>>` | `on(java.lang.Object key, groovy.lang.Closure consumer)` @see #on(reactor.bus.selector.Selector, reactor.fn.Consumer)
    `reactor.bus.registry.Registration<java.lang.Object, reactor.fn.Consumer<E>>` | `on(java.lang.Object key, reactor.fn.Consumer<E> consumer)` @see #on(reactor.bus.selector.Selector, reactor.fn.Consumer)
    `reactor.bus.registry.Registration<java.lang.Object, reactor.fn.Consumer<E>>` | `on(java.lang.Class type, reactor.fn.Consumer<E> consumer)` @see #on(reactor.bus.selector.Selector, reactor.fn.Consumer)
    `reactor.bus.registry.Registration<java.lang.Object, reactor.fn.Consumer<E>>` | `on(reactor.bus.selector.Selector sel, reactor.fn.Consumer<E> consumer)` Register a reactor.fn.Consumer to be triggered when a notification matches the given reactor.bus.selector.Selector.
    `reactor.bus.Bus` | `sendAndReceive(java.lang.Object key, java.lang.Object data, groovy.lang.Closure reply)` @see EventBus#sendAndReceive(java.lang.Object, reactor.bus.Event, reactor.fn.Consumer)
    `reactor.bus.Bus` | `sendAndReceive(java.lang.Object key, groovy.lang.Closure<E> supplier, groovy.lang.Closure reply)` @see EventBus#sendAndReceive(java.lang.Object, reactor.fn.Supplier, reactor.fn.Consumer)

- - ### Property Detail

    - #### @org.springframework.beans.factory.annotation.Autowired reactor.bus.EventBus eventBus

  - ### Method Detail

    - #### boolean clearEventConsumers(java.lang.Object key)

      Clears event consumers for the given key

      Parameters:
        `key` - The key
      Returns:
        True if modifications were made

    - #### reactor.bus.Event<T> eventFor(T data)

      Creates an reactor.bus.Event for the given data

      Parameters:
        `data` - The data
      Returns:
        The event

    - #### reactor.bus.Event<T> eventFor(java.util.Map<java.lang.String, java.lang.Object> headers, T data)

      Creates an reactor.bus.Event for the given headers and data

      Parameters:
        `headers` - The headers
        `data` - The data
      Returns:
        The event

    - #### reactor.bus.Event<T> eventFor(java.util.Map<java.lang.String, java.lang.Object> headers, T data, groovy.lang.Closure<java.lang.Throwable> errorConsumer)

      Creates an reactor.bus.Event for the given headers, data and error consumer

      Parameters:
        `headers` - The headers
        `data` - The data
        `errorConsumer` - The errors consumer
      Returns:
        The event

    - #### reactor.bus.Bus notify(java.lang.Object key, reactor.bus.Event<?> ev)

      See Also:
        reactor.bus.Bus#notify(java.lang.Object, java.lang.Object)

    - #### reactor.bus.Bus notify(java.lang.Object key, java.lang.Object data)

      See Also:
        reactor.bus.Bus#notify(java.lang.Object, reactor.bus.Event)

    - #### reactor.bus.Bus notify(java.lang.Object key, groovy.lang.Closure<E> supplier)

      See Also:
        reactor.bus.Bus#notify(java.lang.Object, reactor.bus.Event)

    - #### reactor.bus.registry.Registration<java.lang.Object, reactor.fn.Consumer<E>> on(java.lang.Class key, @groovy.lang.DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = ClosureEventConsumer.ReplyDecorator) groovy.lang.Closure consumer)

      See Also:
        on(reactor.bus.selector.Selector, reactor.fn.Consumer)

    - #### reactor.bus.registry.Registration<java.lang.Object, reactor.fn.Consumer<E>> on(reactor.bus.selector.Selector key, @groovy.lang.DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = ClosureEventConsumer.ReplyDecorator) groovy.lang.Closure consumer)

      See Also:
        on(reactor.bus.selector.Selector, reactor.fn.Consumer)

    - #### reactor.bus.registry.Registration<java.lang.Object, reactor.fn.Consumer<E>> on(java.lang.Object key, @groovy.lang.DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = ClosureEventConsumer.ReplyDecorator) groovy.lang.Closure consumer)

      See Also:
        on(reactor.bus.selector.Selector, reactor.fn.Consumer)

    - #### reactor.bus.registry.Registration<java.lang.Object, reactor.fn.Consumer<E>> on(java.lang.Object key, reactor.fn.Consumer<E> consumer)

      See Also:
        on(reactor.bus.selector.Selector, reactor.fn.Consumer)

    - #### reactor.bus.registry.Registration<java.lang.Object, reactor.fn.Consumer<E>> on(java.lang.Class type, reactor.fn.Consumer<E> consumer)

      See Also:
        on(reactor.bus.selector.Selector, reactor.fn.Consumer)

    - #### reactor.bus.registry.Registration<java.lang.Object, reactor.fn.Consumer<E>> on(reactor.bus.selector.Selector sel, reactor.fn.Consumer<E> consumer)

      Register a reactor.fn.Consumer to be triggered when a notification matches the given reactor.bus.selector.Selector.

      Parameters:
        `sel` - The Selector to be used for matching
        `consumer` - The Consumer to be triggered
        `` - The type of the reactor.bus.Event
      Returns:
        A reactor.bus.registry.Registration object that allows the caller to interact with the given mapping

    - #### reactor.bus.Bus sendAndReceive(java.lang.Object key, java.lang.Object data, @groovy.lang.DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = ClosureEventConsumer.ReplyDecorator) groovy.lang.Closure reply)

      See Also:
        EventBus#sendAndReceive(java.lang.Object, reactor.bus.Event, reactor.fn.Consumer)

    - #### reactor.bus.Bus sendAndReceive(java.lang.Object key, groovy.lang.Closure<E> supplier, @groovy.lang.DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = ClosureEventConsumer.ReplyDecorator) groovy.lang.Closure reply)

      See Also:
        EventBus#sendAndReceive(java.lang.Object, reactor.fn.Supplier, reactor.fn.Consumer)