proton_client

    Typed asynchronous frontend client for Proton applications.

    proton
    client
    ipc
    Download zip
    Version
    0.2.9
    License
    Apache-2.0
    Last updated
    13 days ago
    Downloads
    172

    #Proton Client

    moonbit-community/proton_client invokes typed Proton contracts from the active renderer page. It uses the bridge installed by Proton before application scripts run; applications do not construct a client or select a transport.

    ///|
    async fn load_todos {
    let snapshot = @proton_client.invoke(@shared.list_todos, {})
    render(snapshot)
    }

    Requests are encoded and responses are decoded at the client boundary. Transport, timeout, cancellation, remote execution, and decoding failures are raised as ClientFailure.

    ClientFailure

    pub(all) suberror ClientFailure {
    BridgeUnavailable
    RequestCancelled
    InvalidContract(message~ : String)
    RemoteFailure(code~ : String, message~ : String, detail~ : String?)
    TransportFailure(message~ : String)
    ResponseDecode(message~ : String)
    EventDecode(message~ : String)
    } derive(Eq,
    Debug
    )

    Failures raised by the typed frontend client.

    ClientFailure::equal

    ClientFailure::message

    fn ClientFailure::message(self : ClientFailure) -> String

    Returns a user-facing description of this client failure.

    ClientFailure::not_equal

    fn ClientFailure::not_equal(x : ClientFailure, y : ClientFailure) -> Bool

    ClientFailure::output

    fn ClientFailure::output(self : ClientFailure, logger : &Logger) -> Unit

    ClientFailure::to_string

    fn ClientFailure::to_string(self : ClientFailure) -> String

    Subscription

    pub struct Subscription {
    closed : Bool
    close_listener : () -> Unit
    }

    A live event subscription installed on the active renderer page.

    Subscription::close

    fn Subscription::close(self : Subscription) -> Unit

    Removes this subscription. Repeated calls have no effect.

    invoke

    async fn[Request : ToJson, Response :
    FromJson
    ] invoke(command :
    Command
    [Request, Response], request : Request) -> Response raise ClientFailure

    Invokes a typed command through the bridge installed on the active page.

    subscribe

    fn[Payload :
    FromJson
    ] subscribe(event :
    Event
    [Payload], received : (Payload) -> Unit, failure : (ClientFailure) -> Unit) -> Subscription raise ClientFailure

    Subscribes to a typed live event on the active renderer page.

    A malformed payload reports EventDecode through failure without removing the subscription.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io