figbus / elm-urbit-api

Elm wrapper for the Urbit HTTP API

Home Page:https://package.elm-lang.org/packages/figbus/elm-urbit-api/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Elm Urbit HTTP API

This is an Elm wrapper for the Urbit HTTP API, making it easy to interact with Urbit from any Elm application.

Examples

import Random
import Time
import Json.Encode
import Urbit

connect : Int -> Time.Posix -> Cmd Msg
connect entropy time =
    Urbit.connect
        { ship = zod
        , url = "http://localhost:8080"
        , channelId =
            Random.initialSeed entropy
                |> Random.step (Urbit.channelId time)
                |> Tuple.first
        , code = "lidlut-tabwed-pillex-ridrup"
        }
        GotConnection

poke : Urbit.Session -> ( Urbit.Session, Cmd Msg )
poke session =
    Urbit.poke
        { ship = zod
        , app = "hood"
        , mark = "helm-hi"
        , json = Json.Encode.string "opening airlock"
        }
        |> Urbit.send session PokedHood

See the example/ folder for a more complete example.

Ports Disclaimer

Because Elm does not support the EventSource API, some additional work is required to create the ports necessary for most functionality. See the Urbit.setupEventSource documentation for details.

About

Elm wrapper for the Urbit HTTP API

https://package.elm-lang.org/packages/figbus/elm-urbit-api/latest/

License:MIT License


Languages

Language:Elm 99.1%Language:JavaScript 0.6%Language:HTML 0.3%