LimitSubscribers Operator

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

Guard structure used in limit_subscribers operator.

Arguments

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

Note

This structure is useful in Pluto.jl notebooks in particular, allowing for automatic subscription/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 number of concurrent actors to the given observable. On new subscription, if limit is exceeded, oldest actor is automatically unsubscribed and receives a completion event.

Arguments

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

Note

This structure is useful in Pluto.jl notebooks in particular, allowing for automatic subscription/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