carb::events::createSubscriptionToPop

Defined in carb/events/EventsUtils.h

inline ObjectPtr<ISubscription> carb::events::createSubscriptionToPop(IEventStream *stream, std::function<void(IEvent*)> onEventFn, Order order = kDefaultOrder, const char *subscriptionName = nullptr)

A helper for IEvents::createSubscriptionToPop() that creates a LambdaEventListener.

Parameters
  • stream – The IEventStream to use.

  • onEventFn – A handler that will be invoked for each carb::events::IEvent that is popped.

  • order – An optional value used to specify the order tier. Lower order tiers will be notified first. Multiple IEventListener objects at the same order tier are notified in an undefined order.

  • subscriptionName – An optional name for the subscription. Names do not need to be unique.

Returns

A ISubscription pointer. The subscription is valid as long as the ISubscription pointer is referenced. Alternately, the IEventListener can be unsubscribed by calling ISubscription::unsubscribe().