Events Reference
Events can be published, subscribed, or created by an custom service, component model, or component.
Publishing Events
Events can be published by calling the .publish
method on the event object.
In both components and services, event objects are accessed by injecting the relevant event reference class.
tip
The AllEvents
class is a repository of all available events in the Geocortex Mobile SDK
Subscribing to Events
Events can be subscribed to by calling the .subscribe
method on the event object.
In both components and services, event objects are accessed by injecting the event reference class.
important
It is vital that subscription handles are cleaned up when the object is cleaned up, otherwise dangling references can occur. This can be done by implementing the IDisposable
and IDisposableTracker
interface, and then providing this
as the second argument to a call to subscribe. ServiceBase
and ComponentBase
already implement these interfaces so you don't have to.
Creating Custom Events
Custom events in Geocortex Mobile are created through the IEventRegistry
. Events can be directly created in any component or service that can inject this class, but it is best practice to define events in a class that extends EventsBase
and registers with Autofac. This allows your events to be injected and referenced by any component or service across the app.
Event Arguments
Events optionally take a type argument, which represents the object associated with the event consumed by the subscriber. This can be a simple or complex object.