-
Notifications
You must be signed in to change notification settings - Fork 5
Events
The messaging system of this framework works based on the idea that if a module is an EventsProducer
it will expose an observable of EventProtocol
.
An EventProtocol
is usually an enum that collects a series of cases. Each one of them represents an event that can be emitted by the EventsProducer
.
Example:
public enum ProductDetailPageEvent: EventProtocol {
case productLoaded(FullProductProtocol)
case didAddToCart(BagProductProtocol)
case didAddProductToWaitlist(FullProductProtocol)
case didShareProduct(MinimumProductProtocol)
case didChangeSize(newSize: ProductSizeProtocol)
case didChangeColor(newColor: ProductColorProtocol)
}
This enum ProductDetailPageEvent
is exposing all the events that can happen on a Product Detail page.
The user can add the product to the cart, to the waitlist, he can share the product, change its size and colour. You can add to this enum any event you believe it makes sense for your events listeners to be tracked. For example, you might want to track users behaviours like didSwipeImage
in an analytics events listener that the user used the swipe feature of the image carousel. This events list can be unlimited and all depends on your requirements and which events actually makes sense for your module to expose.