class LiveProp implements SupportsLiveUpdates

Traits

Properties

protected bool $live

Indicates if the property should receive live updates.

from  HasLiveUpdates
protected array<int, array{events: array<int, class-string|object|Channel|string>}> $liveDeclarations

The events and channels each [live] call declared, kept per call so an explicit channel only applies to its own events.

from  HasLiveUpdates
protected int|null $liveThrottle

The number of milliseconds to throttle live updates by.

from  HasLiveUpdates
protected mixed $value

The property value.

Methods

live(array|object|string|null $on = null, array|Channel|string|null $channel = null, int|null $throttle = null)

Mark the property as live, refreshing it whenever one of the given events is received. Merge properties cannot be live.

bool
isLive()

Determine if the property should receive live updates.

int|null
liveThrottle()

Get the number of milliseconds to throttle live updates by.

array
liveListeners()

Get the live-update listeners that should refresh the property. A channel passed to [live] applies only to the events it was passed with.

string
resolveEventName(object|string $event)

Resolve the name Hypervel broadcasts the given event as.

array
channelsFromEvent(object|string $event)

Gather the channels the given event broadcasts on. A class name is built without its payload, which is all an event needs when its channels do not depend on one.

array
broadcastChannels(object $event)

Read the channels off an event instance.

array
channelsForDefaultConnection(object $event, array $channels)

Get the channels the given event broadcasts on for the default connection.

void
addLiveListener(array $listeners, array $channel, array $events)

Add the given events to the listener for the given channel.

array
resolveChannels(array $channels)

Resolve the given channels into the unprefixed names and types the broadcaster sends them on.

array
resolveChannel(Channel|HasBroadcastChannel|string $channel)

Resolve the given channel into its unprefixed name and type. Hypervel's prefixes follow Pusher's convention, so transports get the type separately and apply their own naming.

string
channelType(Channel $channel)

Resolve the type of the given channel.

string
channelName(Channel $channel, string $type)

Resolve the name of the given channel, without the prefix Hypervel's channel class added to it.

mixed
invokeCallable(callable $value)

Invoke a value whose public contract guarantees it is callable.

mixed
resolveCallable(mixed $value)

Call the given value if callable and inject its dependencies.

bool
useAsCallable(mixed $value)

Determine if the given value is callable, but not a string.

__construct(mixed $value, array|object|string|null $on = null, array|Channel|string|null $channel = null, int|null $throttle = null)

Create a new live property instance. Live properties are refreshed with a partial reload whenever one of the given events is received.

mixed
__invoke()

Resolve the property value.

Details

in HasLiveUpdates at line 58
HasLiveUpdates live(array|object|string|null $on = null, array|Channel|string|null $channel = null, int|null $throttle = null)

Mark the property as live, refreshing it whenever one of the given events is received. Merge properties cannot be live.

Parameters

array|object|string|null $on
array|Channel|string|null $channel
int|null $throttle

Return Value

HasLiveUpdates

in HasLiveUpdates at line 77
bool isLive()

Determine if the property should receive live updates.

Return Value

bool

in HasLiveUpdates at line 85
int|null liveThrottle()

Get the number of milliseconds to throttle live updates by.

Return Value

int|null

in HasLiveUpdates at line 96
array liveListeners()

Get the live-update listeners that should refresh the property. A channel passed to [live] applies only to the events it was passed with.

Return Value

array

in HasLiveUpdates at line 128
protected string resolveEventName(object|string $event)

Resolve the name Hypervel broadcasts the given event as.

Parameters

object|string $event

Return Value

string

in HasLiveUpdates at line 168
protected array channelsFromEvent(object|string $event)

Gather the channels the given event broadcasts on. A class name is built without its payload, which is all an event needs when its channels do not depend on one.

Parameters

object|string $event

Return Value

array

in HasLiveUpdates at line 196
protected array broadcastChannels(object $event)

Read the channels off an event instance.

Parameters

object $event

Return Value

array

in HasLiveUpdates at line 223
protected array channelsForDefaultConnection(object $event, array $channels)

Get the channels the given event broadcasts on for the default connection.

Parameters

object $event
array $channels

Return Value

array

in HasLiveUpdates at line 253
protected void addLiveListener(array $listeners, array $channel, array $events)

Add the given events to the listener for the given channel.

Parameters

array $listeners
array $channel
array $events

Return Value

void

in HasLiveUpdates at line 275
protected array resolveChannels(array $channels)

Resolve the given channels into the unprefixed names and types the broadcaster sends them on.

Parameters

array $channels

Return Value

array

in HasLiveUpdates at line 322
protected array resolveChannel(Channel|HasBroadcastChannel|string $channel)

Resolve the given channel into its unprefixed name and type. Hypervel's prefixes follow Pusher's convention, so transports get the type separately and apply their own naming.

Parameters

Channel|HasBroadcastChannel|string $channel

Return Value

array

in HasLiveUpdates at line 346
protected string channelType(Channel $channel)

Resolve the type of the given channel.

Parameters

Channel $channel

Return Value

string

in HasLiveUpdates at line 359
protected string channelName(Channel $channel, string $type)

Resolve the name of the given channel, without the prefix Hypervel's channel class added to it.

Parameters

Channel $channel
string $type

Return Value

string

in ResolvesCallables at line 14
protected mixed invokeCallable(callable $value)

Invoke a value whose public contract guarantees it is callable.

Parameters

callable $value

Return Value

mixed

in ResolvesCallables at line 22
protected mixed resolveCallable(mixed $value)

Call the given value if callable and inject its dependencies.

Parameters

mixed $value

Return Value

mixed

in ResolvesCallables at line 30
protected bool useAsCallable(mixed $value)

Determine if the given value is callable, but not a string.

Parameters

mixed $value

Return Value

bool

at line 26
__construct(mixed $value, array|object|string|null $on = null, array|Channel|string|null $channel = null, int|null $throttle = null)

Create a new live property instance. Live properties are refreshed with a partial reload whenever one of the given events is received.

Parameters

mixed $value
array|object|string|null $on
array|Channel|string|null $channel
int|null $throttle

at line 35
mixed __invoke()

Resolve the property value.

Return Value

mixed