package bonsai

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

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 : (module Bonsai.Model with type t = 'query) -> ('query, 'response) t Bonsai.Value.t -> 'query Bonsai.Value.t -> ('query, 'response) Poll_result.t Bonsai.Computation.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 : ('query, _) Bonsai.comparator -> f: ('query Bonsai.For_open.Value.t -> ('query, 'response) Poll_result.t Bonsai.For_open.Computation.t) -> ('query, 'response) t Bonsai.For_open.Computation.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.

OCaml

Innovation. Community. Security.