Earth to Mars communication done right
Go to file
2023-08-25 11:42:41 +03:00
.github/workflows Create ci.yml (#2) 2023-06-01 17:45:46 +03:00
dev %sink (#6) 2023-07-05 12:28:07 +03:00
docs Added some docs (#7) 2023-07-09 20:11:38 +03:00
example Simplified deconstructors (#11) 2023-07-28 16:14:30 +03:00
res Added basic readme (#5) 2023-06-18 13:03:37 +03:00
src Added debugger (#14) 2023-08-24 19:15:35 +03:00
tests/Test Simplified deconstructors (#11) 2023-07-28 16:14:30 +03:00
.gitignore %sink (#6) 2023-07-05 12:28:07 +03:00
elm.json Bumped version 2023-08-25 11:42:41 +03:00
LICENSE Added license 2023-07-31 17:17:32 +03:00
README.md Update README 2023-08-25 11:42:16 +03:00

Airlock

Usage

Demo

DEMO

Getting started

The easiest way of using this library is by using the airlock template.

FFI

This is for setting up this library from scratch.

Urbit subscriptions require server-side event (SSE). Unfortunately, Elm does not provide a native implementation. This means that we will need to use JS FFI (aka ports).

Setting up the Elm side

You would need to declare two ports for Airlock to use:

  1. port createEventSource : String -> Cmd msg

    This sets up the SSE channel.

  2. port onEventSourceMessage : (JD.Value -> msg) -> Sub msg This recieves the actual messages from the SSE channel.

These two functions need to be passed to one of the functions from Ur.Run module. The functions in Ur.Run are the same as functions from Browser, but have a couple of extra urbit-specific fields.

Setting up the JS side

The SSE JS code is neatly packed into example/fetch-event-source.js. All you need to do is pass them to Elm ports like in example/script.js.

You can see a full working example in example.