package babel

  1. Overview
  2. Docs

High level functions for working with callers in the style of Async.Rpc.State_rpc.dispatch.

val dispatch_multi : ('q, 's, 'u, 'e) dispatch t -> Async_rpc_kernel.Versioned_rpc.Connection_with_menu.t -> ('q, 's, 'u, 'e) dispatch

Determine which supported dispatch strategy to use and invoke the chosen rpcs. To unsubscribe, you can close the pipe.

val singleton : ('q, 's, 'u, 'e) Async_rpc_kernel.Rpc.State_rpc.t -> ('q, 's, 'u, 'e) dispatch t

Create a new caller supporting a single rpc.

val add : ('q, 's, 'u, 'e) dispatch t -> rpc:('q, 's, 'u, 'e) Async_rpc_kernel.Rpc.State_rpc.t -> ('q, 's, 'u, 'e) dispatch t

Add support for dispatching another rpc. dispatch_multi will prefer this rpc over the ones the caller already supports.

val map_query : ('q1, 's, 'u, 'e) dispatch t -> f:('q2 -> 'q1) -> ('q2, 's, 'u, 'e) dispatch t

A specialization of map for the query type of a protocol.

val map_state : ('q, 's1, 'u, 'e) dispatch t -> f:('s1 -> 's2) -> ('q, 's2, 'u, 'e) dispatch t

A specialization of map for the state type of a protocol.

val map_update : ('q, 's, 'u1, 'e) dispatch t -> f:('u1 -> 'u2) -> ('q, 's, 'u2, 'e) dispatch t

A specialization of map for the update type of a protocol.

Sometimes, Caller.State_rpc.map_update is not sufficient. For example, sometimes it might not be possible to convert the response to the desired type, in which case it may be appropriate to drop the value from the pipe entirely. For such cases, use Caller.map_response instead. It gives you access to the pipe itself, not just the values inside it, allowing you to use something like Pipe.filter_map.

val filter_map_update : ('q, 's, 'u1, 'e) dispatch t -> f:('u1 -> 'u2 option) -> ('q, 's, 'u2, 'e) dispatch t

Same as map_update but filters out some responses from the response pipe

val map_error : ('q, 's, 'u, 'e1) dispatch t -> f:('e1 -> 'e2) -> ('q, 's, 'u, 'e2) dispatch t

A specialization of map for the error type of a protocol.

OCaml

Innovation. Community. Security.