Module Rpc_effect_kernel.Shared_poller

A Shared_poller is a handle to a polling-style RPC whose RPCs can be shared between multiple components that might have an interest in polling values with the same types.

To create a Shared_poller, use either Rpc_effect.Rpc.shared_poller or Rpc_effect.Polling_state_rpc.shared_poller. With the value returned by those functions, you can call Shared_poller.lookup with a query value to get access to the results of the given RPC with the provided query.

type ('query, 'response) t
val lookup : here:lexing_position -> ('query, 'response) t Bonsai.t -> 'query Bonsai.t -> output_type:('query, 'response, 'output) Poll_result.Output_type.t -> Bonsai.graph @ local -> 'output Bonsai.t

Uses a shared-poller to either start polling an RPC, or if another user of the same shared-poller is already polling with the same query, it'll immediately return the most recent value.

val custom_create : here:lexing_position -> ('query, _) Core.Comparator.Module.t -> f: ('query Bonsai.t -> Bonsai.graph @ local -> ('query, 'response) Poll_result.t Bonsai.t) -> Bonsai.graph @ local -> ('query, 'response) t Bonsai.t

You can use custom_create to build a shared-poller if the Rpc_effect.Rpc.shared_poller and Rpc_effect.Polling_state_rpc.shared_poller aren't sufficient. You'll likely want to wrap any shared poller in a Bonsai.scope_model on ~where_to_connect.