9[](https://www.youtube.com/watch?v=tynCzifvIzE)
14The easiest way of using this library is by using the [airlock template](https://github.com/ilyakooo0/airlock-template).
18This is for setting up this library from scratch.
20Urbit subscriptions require [server-side event (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events).
21Unfortunately, Elm does not provide a native implementation.
22This means that we will need to use [JS FFI (aka ports)](https://guide.elm-lang.org/interop/ports.html).
24#### Setting up the Elm side
26You would need to declare two ports for Airlock to use:
281. `port createEventSource : String -> Cmd msg`
30 This sets up the SSE channel.
312. `port onEventSourceMessage : (JD.Value -> msg) -> Sub msg`
32 This recieves the actual messages from the SSE channel.
34These two functions need to be passed to one of the functions from `Ur.Run` module.
35The functions in `Ur.Run` are the same as functions from `Browser`, but have a couple of extra urbit-specific fields.
37#### Setting up the JS side
39The SSE JS code is neatly packed into [example/fetch-event-source.js](example/fetch-event-source.js).
40All you need to do is pass them to Elm ports like in [example/script.js](example/script.js).
42You can see a full working example in [example](example).
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list