PHP API: IR/Effect

Classes in the IR/Effect namespace.

DocumentTarget

Source: DocumentTarget.php

Effect target bound to `document`.

Group: IR/Effect

Example

PHP

$target = new DocumentTarget();

Methods

jsonSerialize

PHP

public function jsonSerialize(): array 

Encode this target as runtime IR payload.

Returns: array<string, string>

EventTrigger

Source: EventTrigger.php

Effect trigger for DOM events.

Supports self, window, or document event sources.

Group: IR/Effect

Example

PHP

$trigger = new EventTrigger('window', 'resize');

Methods

__construct

PHP

public function __construct(
        public readonly string $on,         // 'self' | 'window' | 'document'
        public readonly string $event,
        public readonly ?array $options = null
    ) 

Build an event trigger.

Parameters

  • string $on Event source: self|window|document.
  • string $event Event name.
  • array<string, mixed>|null $options Optional listener options.

type

PHP

public function type(): string 

Return trigger discriminator.

Returns: string

jsonSerialize

PHP

public function jsonSerialize(): array 

Encode this trigger as runtime IR payload.

Returns: array<string, mixed>

IntervalTrigger

Source: IntervalTrigger.php

Effect trigger fired on a fixed interval.

Group: IR/Effect

Example

PHP

$trigger = new IntervalTrigger(1000);

Methods

__construct

PHP

public function __construct(public readonly int $ms) 

Build an interval trigger.

Parameters

  • int $ms Interval in milliseconds.

type

PHP

public function type(): string 

Return trigger discriminator.

Returns: string

jsonSerialize

PHP

public function jsonSerialize(): array 

Encode this trigger as runtime IR payload.

Returns: array<string, int|string>

MountTrigger

Source: MountTrigger.php

Effect trigger fired on mount.

Group: IR/Effect

Example

PHP

$trigger = new MountTrigger();

Methods

type

PHP

public function type(): string 

Return trigger discriminator.

Returns: string

jsonSerialize

PHP

public function jsonSerialize(): array 

Encode this trigger as runtime IR payload.

Returns: array<string, string>

SelectorTarget

Source: SelectorTarget.php

Effect target bound to a CSS selector.

Group: IR/Effect

Example

PHP

$target = new SelectorTarget('#app');

Methods

__construct

PHP

public function __construct(public readonly string $selector) 

Build a selector target.

Parameters

  • string $selector CSS selector string.

jsonSerialize

PHP

public function jsonSerialize(): array 

Encode this target as runtime IR payload.

Returns: array<string, string>

SseTrigger

Source: SseTrigger.php

Effect trigger for Server-Sent Events streams.

Group: IR/Effect

Example

PHP

$trigger = new SseTrigger('/events', 'message', 'json', false, null);

Methods

__construct

PHP

public function __construct(
        public readonly Expr|string $url,
        public readonly string $event = 'message',
        public readonly string $parse = 'json',          // 'json'|'text'|'raw'
        public readonly bool $withCredentials = false,
        public readonly Expr|int|null $sinceId = null    // optional ?sinceId=...
    ) 

Build an SSE trigger.

Parameters

  • Expr|string $url SSE endpoint URL.
  • string $event SSE event name.
  • string $parse Payload parsing mode: json|text|raw.
  • bool $withCredentials Whether EventSource should use credentials.
  • Expr|int|null $sinceId Optional replay id.

type

PHP

public function type(): string 

Return trigger discriminator.

Returns: string

jsonSerialize

PHP

public function jsonSerialize(): array

Encode this trigger as runtime IR payload.

Returns: array<string, mixed>

TimeoutTrigger

Source: TimeoutTrigger.php

Effect trigger fired once after a delay.

Group: IR/Effect

Example

PHP

$trigger = new TimeoutTrigger(250);

Methods

__construct

PHP

public function __construct(public readonly int $ms) 

Build a timeout trigger.

Parameters

  • int $ms Delay in milliseconds.

type

PHP

public function type(): string 

Return trigger discriminator.

Returns: string

jsonSerialize

PHP

public function jsonSerialize(): array 

Encode this trigger as runtime IR payload.

Returns: array<string, int|string>

VisibleTrigger

Source: VisibleTrigger.php

Effect trigger based on element visibility.

Group: IR/Effect

Example

PHP

$trigger = new VisibleTrigger(0.5, '0px', 'enter');

Methods

__construct

PHP

public function __construct(
        public readonly float $threshold = 0.0,
        public readonly ?string $rootMargin = null,
        public readonly ?string $when = 'enter'
    ) 

Build a visibility trigger.

Parameters

  • float $threshold Intersection threshold between 0 and 1.
  • string|null $rootMargin Optional root margin.
  • string|null $when Visibility phase (e.g. enter/leave).

type

PHP

public function type(): string 

Return trigger discriminator.

Returns: string

jsonSerialize

PHP

public function jsonSerialize(): array 

Encode this trigger as runtime IR payload.

Returns: array<string, mixed>

WatchTrigger

Source: WatchTrigger.php

Effect trigger for expression dependency changes.

Group: IR/Effect

Example

PHP

$trigger = new WatchTrigger(Expr::read($count), true, 100, null);

Methods

__construct

PHP

public function __construct(
        public readonly Expr $expr,
        public readonly bool $immediate = false,
        public readonly int|Expr|null $debounceMs = null,
        public readonly int|Expr|null $throttleMs = null,
    ) 

Build a watch trigger.

Parameters

  • Expr $expr Expression to observe.
  • bool $immediate Run once immediately when mounted.
  • int|Expr|null $debounceMs Optional debounce delay.
  • int|Expr|null $throttleMs Optional throttle delay.

type

PHP

public function type(): string 

Return trigger discriminator.

Returns: string

jsonSerialize

PHP

public function jsonSerialize(): array 

Encode this trigger as runtime IR payload.

Returns: array<string, mixed>

validate

PHP

private function validate() 

Validate timing options.

Returns: void

WindowTarget

Source: WindowTarget.php

Effect target bound to `window`.

Group: IR/Effect

Example

PHP

$target = new WindowTarget();

Methods

jsonSerialize

PHP

public function jsonSerialize(): array 

Encode this target as runtime IR payload.

Returns: array<string, string>