@@ -11,24 +11,36 @@ import Ur.Deconstructor as D
11import Ur.Sub.Internal
11import Ur.Sub.Internal
14+{-| Like `Sub` from `Platform.Sub`, but for Urbit subscriptions.
15type alias Sub msg =
16type alias Sub msg =
16 Ur.Sub.Internal.Sub msg
17 Ur.Sub.Internal.Sub msg
20+{-| Creates an Urbit subscription.
25+ , path = [ "updates" ]
26+ , deconstructor = decodeJournalUpdate |> D.map GotUpdate
20subscribe : { ship : String, app : String, path : List String, deconstructor : D.Deconstructor (msg -> msg) msg } -> Sub msg
30subscribe : { ship : String, app : String, path : List String, deconstructor : D.Deconstructor (msg -> msg) msg } -> Sub msg
21subscribe { ship, app, path, deconstructor } =
31subscribe { ship, app, path, deconstructor } =
22 Dict.singleton ( ship, app, path ) deconstructor |> Ur.Sub.Internal.Sub
32 Dict.singleton ( ship, app, path ) deconstructor |> Ur.Sub.Internal.Sub
35+{-| A subscription that does exactly nothing. (Does not subscribe to anything)
26none : Sub msg
37none : Sub msg
28 Ur.Sub.Internal.Sub Dict.empty
39 Ur.Sub.Internal.Sub Dict.empty
42+{-| Batch multiple subscriptions into one.
32batch : List (Sub msg) -> Sub msg
44batch : List (Sub msg) -> Sub msg
33batch subs =
45batch subs =
34 subs |> List.map (\(Ur.Sub.Internal.Sub dict) -> dict) |> List.foldl Dict.union Dict.empty |> Ur.Sub.Internal.Sub
46 subs |> List.map (\(Ur.Sub.Internal.Sub dict) -> dict) |> List.foldl Dict.union Dict.empty |> Ur.Sub.Internal.Sub