Class ScyllaEvent
Abstract base class for all events in the Scylla Event eXchange System (SEX). Every custom event type must inherit from this class to be publishable and subscribable through IScyllaEventBus.
Inheritance
Inherited Members
Namespace: Scylla.Core.Events
Assembly: ScyllaCore.dll
Syntax
public abstract class ScyllaEvent
Remarks
An event instance carries data from the publisher to all interested subscribers. Data is stored as plain C# properties or fields on the derived class; the base class only maintains the propagation state used by the bus during dispatch.
A handler can stop further delivery to lower-priority subscribers by calling StopPropagation(). Once cancelled, the bus skips all remaining handlers except those registered with Essential or Cleanup, which always execute regardless of cancellation state.
Event instances are created by the publisher and passed directly to Publish<TEvent>(TEvent) or the convenience method Publish<TEvent>(TEvent). The same instance is shared across all handlers in a single dispatch call; mutations made by one handler (including cancellation) are visible to subsequent handlers.
Defining a custom event:
public class PlayerDiedEvent : ScyllaEvent
{
public string PlayerName { get; }
public int FinalScore { get; }
public PlayerDiedEvent(string playerName, int finalScore)
{
PlayerName = playerName;
FinalScore = finalScore;
}
}
Publishing the event:
ScyllaEvents.Publish(new PlayerDiedEvent("Hero", 4200));
Properties
IsCancelled
Gets a value indicating whether this event has been cancelled and should stop propagating to further subscribers in the dispatch chain.
Declaration
public bool IsCancelled { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Remarks
When true, the event bus skips all handlers whose priority is neither
Essential nor
Cleanup. The property is read-only to external
code; cancellation is triggered exclusively by calling
StopPropagation().
See Also
Methods
StopPropagation()
Cancels further propagation of this event, instructing the event bus to skip all remaining handlers whose priority is not Essential or Cleanup.
Declaration
public void StopPropagation()
Remarks
Calling this method sets IsCancelled to true. The
cancellation takes effect immediately: any handler that has not yet been
invoked in the current dispatch pass will be skipped unless it holds
Essential or
Cleanup priority.
This method is idempotent - calling it multiple times has no additional effect beyond the first invocation.
Cancelling an event inside a handler to prevent lower-priority subscribers from receiving it:
_subscription = ScyllaEvents.Listen<PlayerDiedEvent>(
this,
e =>
{
if (IsGameOver())
{
// Prevent UI and analytics handlers from firing.
e.StopPropagation();
}
},
ScyllaEventPriority.High
);