on master help sign in
Added more docs
commitcd4f7e5dd149afa1fdc58b6c028f48b7708c99f4 authoriko <mail@iko.soy> dateWed 28 Jun 2023, 15:59 (3 years ago) parentd3af603
5 files changed+55−14
src/Ur.elm+18−2 src/Ur/Cmd.elm+18−5 src/Ur/Da.elm+1−1 src/Ur/Run.elm+2−2 src/Ur/Sub.elm+16−4
src/Ur.elm+18−2
@@ -56,7 +56,22 @@ getShipName root =
5656 }
5757
5858
59−{-| -}
59+{-| Scry an agent at some path
60+
61+ scry
62+ { url = "http://localhost:8080"
63+ , agent = "journal"
64+ , path = [ "entries", "all" ]
65+ , error = Noop
66+ , success =
67+ D.cell D.ignore
68+ (D.cell (D.const D.cord "jrnl")
69+ (D.list (D.cell D.bigint D.cord |> D.map (\a b -> ( a, b ))))
70+ |> D.map GotListings
71+ )
72+ }
73+
74+-}
6075scry :
6176 { url : String
6277 , agent : Agent
@@ -69,7 +84,8 @@ scry args =
6984 scryTask args |> Task.perform identity
7085
7186
72−{-| -}
87+{-| Same as `scry` but returns a `Task` instead of a `Cmd`.
88+-}
7389scryTask :
7490 { url : String
7591 , agent : Agent
src/Ur/Cmd.elm+18−5
@@ -10,30 +10,43 @@ import Ur.Cmd.Internal
1010import Ur.Types exposing (Agent, Mark, Noun, Ship)
1111
1212
13−{-| -}
13+{-| Like `Cmd` from `Platform.Cmd`, but for Urbit commands.
14+-}
1415type alias Cmd msg =
1516 List (Ur.Cmd.Internal.Cmd msg)
1617
1718
18−{-| -}
19+{-| A command that does exactly nothing.
20+-}
1921none : Cmd msg
2022none =
2123 []
2224
2325
24−{-| -}
26+{-| Sends a %poke to a Gall Agent.
27+
28+ poke
29+ { ship = "~zod"
30+ , agent = "journal"
31+ , mark = "journal-action"
32+ , noun = C.cell (C.cord "del") (C.bigint id)
33+ }
34+
35+-}
2536poke : { ship : Ship, agent : Agent, mark : Mark, noun : Noun } -> Cmd msg
2637poke p =
2738 [ Ur.Cmd.Internal.Poke p ]
2839
2940
30−{-| -}
41+{-| Turns a `Platform.Cmd` command into a `Ur.Cmd` command.
42+-}
3143cmd : Cmd.Cmd msg -> Cmd msg
3244cmd c =
3345 [ Ur.Cmd.Internal.Cmd c ]
3446
3547
36−{-| -}
48+{-| Batches multiple commands into one. Similar to `Platform.Cmd.batch`.
49+-}
3750batch : List (Cmd msg) -> Cmd msg
3851batch =
3952 List.concat
src/Ur/Da.elm+1−1
@@ -26,7 +26,7 @@ second =
2626 BigInt.fromIntString "18446744073709551616" |> Maybe.withDefault (BigInt.fromInt 0)
2727
2828
29−{-| Converts `Posix` to a `@da`
29+{-| Converts `Posix` to a `@da`.
3030-}
3131posixToDa : Posix -> Da
3232posixToDa p =
src/Ur/Run.elm+2−2
@@ -1,6 +1,6 @@
11module Ur.Run exposing (element, document, application, Program, Model, Msg)
22
3−{-|
3+{-| This module contains functions to run your application with Urbit integration.
44
55@docs element, document, application, Program, Model, Msg
66
@@ -64,7 +64,7 @@ type Msg msg
6464 | RetryRequests
6565
6666
67−{-| A wrapper around your application `Program`
67+{-| A wrapper around your application `Program`.
6868-}
6969type alias Program model msg =
7070 Platform.Program Flags (Model model msg) (Msg msg)
src/Ur/Sub.elm+16−4
@@ -11,24 +11,36 @@ import Ur.Deconstructor as D
1111import Ur.Sub.Internal
1212
1313
14−{-| -}
14+{-| Like `Sub` from `Platform.Sub`, but for Urbit subscriptions.
15+-}
1516type alias Sub msg =
1617 Ur.Sub.Internal.Sub msg
1718
1819
19−{-| -}
20+{-| Creates an Urbit subscription.
21+
22+ subscribe
23+ { ship = ship
24+ , app = "journal"
25+ , path = [ "updates" ]
26+ , deconstructor = decodeJournalUpdate |> D.map GotUpdate
27+ }
28+
29+-}
2030subscribe : { ship : String, app : String, path : List String, deconstructor : D.Deconstructor (msg -> msg) msg } -> Sub msg
2131subscribe { ship, app, path, deconstructor } =
2232 Dict.singleton ( ship, app, path ) deconstructor |> Ur.Sub.Internal.Sub
2333
2434
25−{-| -}
35+{-| A subscription that does exactly nothing. (Does not subscribe to anything)
36+-}
2637none : Sub msg
2738none =
2839 Ur.Sub.Internal.Sub Dict.empty
2940
3041
31−{-| -}
42+{-| Batch multiple subscriptions into one.
43+-}
3244batch : List (Sub msg) -> Sub msg
3345batch subs =
3446 subs |> List.map (\(Ur.Sub.Internal.Sub dict) -> dict) |> List.foldl Dict.union Dict.empty |> Ur.Sub.Internal.Sub