LimitSubscribers Operator

Rocket.LimitSubscribersGuardType
LimitSubscribersGuard(limit::Int = 1, exclusive = true)

Guard structure used in the limit_subscribers operator.

Arguments

  • limit: number of concurrent subscribers
  • exclusive: boolean flag that indicates whether this guard can be shared with other observables in another limit_subscribers operator. If set to true, reusing this guard in a different limit_subscribers operator for another observable results in automatic unsubscription of all present actors.

Note

This structure is useful in Pluto.jl notebooks in particular, allowing for automatic subscription and unsubscription of observables.

Example


# Cell 1
guard = LimitSubscribersGuard()

# Cell 2
subscription = subscribe!(some_stream |> limit_subscribers(guard), logger())

See also: limit_subscribers, subscribe!

source
Rocket.limit_subscribersFunction
limit_subscribers(limit::Int = 1, exclusive::Bool = true)
limit_subscribers(guard::LimitSubscribersGuard)

Creates an operator that limits the number of concurrent actors subscribed to the given observable. On a new subscription, if the limit is exceeded, the oldest actor is automatically unsubscribed and receives a completion event.

Arguments

  • limit: number of concurrent subscribers
  • exclusive: boolean flag that indicates whether this guard can be shared with other observables in another limit_subscribers operator. If set to true, reusing this guard in a different limit_subscribers operator for another observable results in automatic unsubscription of all present actors.

Note

This structure is useful in Pluto.jl notebooks in particular, allowing for automatic subscription and unsubscription of observables.

Example


# Cell 1
guard = LimitSubscribersGuard()

# Cell 2
subscription = subscribe!(some_stream |> limit_subscribers(guard), logger())

See also: LimitSubscribersGuard

source

See also

Operators