Index

SingleSignal

MMO\core\events · 1 symbol · generated 5 Oct 2026

class

SingleSignal

SingleSignal.php:10

Signal that is sent only one time during the application lifecycle.

class MMO\core\events\SingleSignal extends MMO\core\events\Signal use MMO\core\classes\tSingleton
Namespace
MMO\core\events
Extends
Signal
Uses traits
tSingleton

Index

Instantiate($config) static(Re)create the shared instance immediately, configured with $config merged into the class's existing config.
IsShared() static
Send($args) staticSend this signal, but only the FIRST time it's ever called: subsequent calls (with any, even different, $args) just return the same already-dispatched instance, unchanged.
Shared() staticGet the shared instance, creating (and configuring) it on first call.
Unshare($serialize) staticRemove the shared instance, so the next Shared() call creates a fresh one.
Value($args) static
__construct($origin)A singleton: Send (or Shared), never new -- a second instance would dispatch a second time.

Methods7

Instantiate($config)

statictSingleton.php:61

(Re)create the shared instance immediately, configured with $config merged into the class's existing config.

static function Instantiate(array $config = []): staticUnlike a plain [`Shared()`](https://mcp.mmoframework.fr/documentation/mmo.core/php/events/SingleSignal.md#singlesignal-shared) call (which lazily builds the instance from whatever config was already loaded), this lets you supply/override config right before the instance is built.
$config = []arrayconfig values merged in before the instance is constructed
returnsstaticthe newly (re)created shared instance
MyService::Instantiate(['greeting' => 'yo'])->greeting; // 'yo'

IsShared()

statictSingleton.php:49
static function IsShared(): bool
returnsbooltrue if the shared instance has already been created (a call to Shared() would not need to construct a new one)
MyService::IsShared(); // false until the first MyService::Shared() call

Send($args)

staticSingleSignal.php:29

Send this signal, but only the FIRST time it's ever called: subsequent calls (with any, even different, $args) just return the same already-dispatched instance, unchanged.

static function Send(mixed ...$args): static
...$argsmixed
returnsstatic
SingleSignal::Send($origin, 'a'); // actually dispatchesSingleSignal::Send($origin, 'b'); // ignored: returns the same instance from the 'a' call

Shared()

statictSingleton.php:22

Get the shared instance, creating (and configuring) it on first call.

static function Shared(): static
returnsstatic
MyService::Shared()->greeting; // 'hello'

Unshare($serialize)

statictSingleton.php:35

Remove the shared instance, so the next Shared() call creates a fresh one.

static function Unshare(bool $serialize = true): bool
See
serialize) and kept as the class's config, so the next instance created picks up where this one left off; if false, the instance is simply discarded and the next one starts from the class's original config
$serialize = trueboolif true (the default) and an instance currently exists, it is serialized first (via
returnsbooltrue if an instance actually existed and was removed
MyService::Unshare(); // true if MyService::Shared() had already been called; the next call rebuilds it

__construct($origin)

SingleSignal.php:17

A singleton: Send (or Shared), never new -- a second instance would dispatch a second time.

protected function __construct(object|string $origin)
$originobject | string
Inherited members (15)
PropertiesDeclared byDescription
ListenersEvent
originEvent
returnValueSignal
MethodsDeclared byDescription
AddListener($handler, $order)EventRegister a listener directly (as opposed to ConnectListeners's attribute-based discovery).
ConnectListeners($obj)EventScan $obj's methods for #[Listen(EventClass::class)] attributes and register each one as a listener on the matching event class.
DisconnectListeners($obj)EventUndo a previous ConnectListeners: removes every listener that connect had registered for $obj on this event class.
dispatch()EventInvoke every GetListeners listener with $this.
GetListeners()EventCollect every listener for this class, including those registered on its parent classes (so a subclass event is also caught by listeners of its parent event), sorted by ascending $order (ties keep …
getOrigin()Event
getReturn()Signal
HasListener($handler)Event
hasReturn()Signal
RemoveListener($handler)EventRemove the last added handler from the listeners.
SetListenerOrder($handler, $order)EventChange the order of an already-registered listener, whether added directly via AddListener or indirectly via ConnectListeners (which also stores its [$obj, $methodName] callables here).
setReturn($value, $stop)Signal