@rbxts/fletchette
    Preparing search index...

    Class BatchedPropertyPacket<T>

    BatchedPropertyPacket batches property updates so they are delivered no more than once per interval.

    Type Parameters

    • T

      The type of the property

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    batchIntervalMs: number

    Interval between flushes, expressed in milliseconds.

    changed: Signal<(value: T) => void>

    Signal that fires when the property changes. Should only be used on the client since the server does not listen for changes.

    className: "BatchedPropertyPacket"

    Class name of the packet, used for debugging purposes.

    perPlayer?: Map<Player, undefined | T>

    Map of player to their property value

    signalPacket: SignalPacket<(value: T) => void>

    SignalPacket used to send the property

    Methods

    • Clears the value of the property for players that pass the predicate. Should only be used on the server.

      Parameters

      • predicate: (player: Player) => boolean

        The predicate to filter players

      Returns void

    • Returns the current value of the property.

      Parameters

      • Optionalplayer: Player

        The player to get the value for. Does nothing on the client.

      Returns T

      The current value of the property

    • Returns the value of the property for a specific player. Should only be used on the server.

      Parameters

      • player: Player

        The player to get the value for

      Returns T

      The value of the property for the player

      Use get instead.

    • Observes the property for changes. Triggers the handler after each flush.

      Parameters

      • handler: (value: T) => void

        The handler to call when the property changes

      Returns Connection

      A connection that can be disconnected to stop observing the property

    • Sets the value of the property. This will clear the perPlayer map and broadcast the value to all players after the batch interval. Should only be used on the server.

      Parameters

      • value: T

        The new value of the property

      Returns void

    • Sets the value of the property for players that pass the predicate. Should only be used on the server.

      Parameters

      • predicate: (player: Player) => boolean

        The predicate to filter players

      • value: T

        The new value of the property

      Returns void

    • Sets the value of the property for a specific player. Should only be used on the server.

      Parameters

      • player: Player

        The player to set the value for

      • value: T

        The new value of the property

      Returns void

    • Sets the value of the property for a list of players. Should only be used on the server.

      Parameters

      • players: Player[]

        The list of players to set the value for

      • value: T

        The new value of the property

      Returns void

    • Sets the value of the property for players that do not have a value set. Should only be used on the server.

      Parameters

      • value: T

        The new value of the property

      Returns void

    • Overrides the provider used to retrieve players when broadcasting filtered updates. Primarily intended for testing. Passing no provider resets to the default behavior.

      Parameters

      • Optionalprovider: () => Player[]

      Returns void