Skip to content

Commit 08d8400

Browse files
committed
TODO added questions
1 parent 5cec359 commit 08d8400

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/Fabulous/Cmd.fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ module Cmd =
8181
| None -> ()
8282
| Some msg -> dispatch msg ]
8383

84+
//TODO what do I use this for?
8485
/// For building Commands from the return values or exceptions of simple functions,
8586
/// similar to a try/with or try/catch statement.
8687
module OfFunc =
@@ -116,6 +117,7 @@ module Cmd =
116117

117118
[ bind ]
118119

120+
//TODO what do I use this for? Compared to other OfAsync... modules?
119121
/// For building Commands from the return values or exceptions of Async functions,
120122
/// similar to a try/with or try/catch statement.
121123
module OfAsyncWith =
@@ -174,6 +176,7 @@ module Cmd =
174176

175177
[ bind >> start ]
176178

179+
//TODO what do I use this for? Compared to other OfAsync... modules?
177180
/// For building Commands from Async functions started on the thread pool.
178181
module OfAsync =
179182
/// Command that will evaluate an async block and map the result
@@ -195,6 +198,7 @@ module Cmd =
195198
let inline msgOption (task: Async<'msg option>) =
196199
OfAsyncWith.performOption Async.Start (fun () -> task) () id
197200

201+
//TODO what do I use this for? Compared to other OfAsync... modules?
198202
/// For building Commands from Async functions started immediately on the current operating system thread.
199203
module OfAsyncImmediate =
200204
/// Command that will evaluate an async block and map the result
@@ -210,6 +214,7 @@ module Cmd =
210214
let inline attempt (task: 'a -> Async<_>) (arg: 'a) (ofError: _ -> 'msg) : Cmd<'msg> =
211215
OfAsyncWith.attempt Async.StartImmediate task arg ofError
212216

217+
//TODO what do I use this for? Compared to other OfAsync... modules?
213218
/// For building Commands from Task results.
214219
module OfTask =
215220
/// Command to call a task and map the results

src/Fabulous/Program.fs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ namespace Fabulous
33
open System
44
open System.Diagnostics
55

6+
(*TODO Is either of these a program in the Elm sense? If so, where's the view in this one?
7+
Or are these rather abstractions of or pre-cursors to an Elm Program?
8+
AFAIU in the Elm architecture a "program" manages the application's (or component's) state, actions, and view rendering.
9+
Please help me as a MVU/Elm newbie understand these types. *)
10+
//TODO what's the 'arg?
611
/// Configuration of the Fabulous application
712
type Program<'arg, 'model, 'msg> =
813
{
@@ -21,6 +26,7 @@ type Program<'arg, 'model, 'msg> =
2126
ExceptionHandler: exn -> bool
2227
}
2328

29+
//TODO how is this different to the above? What's a 'marker? what's the 'arg?
2430
type Program<'arg, 'model, 'msg, 'marker> =
2531
{
2632
State: Program<'arg, 'model, 'msg>
@@ -66,31 +72,44 @@ module Program =
6672
Logger = ProgramDefaults.defaultLogger()
6773
ExceptionHandler = ProgramDefaults.defaultExceptionHandler }
6874

75+
//TODO when would I use this one? How does it compare to the other stateful* builders?
76+
//TODO what's expected for 'arg?
6977
/// Create a program using an MVU loop
7078
let stateful (init: 'arg -> 'model) (update: 'msg -> 'model -> 'model) =
7179
define (fun arg -> init arg, Cmd.none) (fun msg model -> update msg model, Cmd.none)
7280

81+
//TODO when would I use this one? How does it compare to the other stateful* builders?
82+
//TODO please explain the concept Cmd<'msg>
83+
//TODO what's expected for 'arg?
7384
/// Create a program using an MVU loop
7485
let statefulWithCmd (init: 'arg -> 'model * Cmd<'msg>) (update: 'msg -> 'model -> 'model * Cmd<'msg>) = define init update
7586

87+
//TODO when would I use this one? How does it compare to the other stateful* builders?
88+
//TODO please explain the concept CmdMsg vs. Cmd<'msg>
89+
//TODO what's expected for 'arg?
7690
/// <summary>
7791
/// Create a program using an MVU loop supporting CmdMsg.
7892
/// See also
7993
/// <seealso href="https://elmprogramming.com/elm-architecture-conclusion.html" />
94+
/// ?
8095
/// </summary>
8196
let statefulWithCmdMsg (init: 'arg -> 'model * 'cmdMsg list) (update: 'msg -> 'model -> 'model * 'cmdMsg list) (mapCmd: 'cmdMsg -> Cmd<'msg>) =
8297
let mapCmds cmdMsgs = cmdMsgs |> List.map mapCmd |> Cmd.batch
8398
define (fun arg -> let m, c = init arg in m, mapCmds c) (fun msg model -> let m, c = update msg model in m, mapCmds c)
8499

100+
(*TODO Subscriptions will be started or stopped automatically to match.
101+
- I don't understand what that means. What (other?) Subscriptions - or - to match what?*)
85102
/// <summary>
86103
/// Subscribe to external source of events, overrides existing subscription.
87104
/// Return the subscriptions that should be active based on the current model.
88105
/// Subscriptions will be started or stopped automatically to match.
89106
/// See also
90107
/// <seealso href="https://elmprogramming.com/subscriptions.html" />
108+
/// ?
91109
/// </summary>
92110
let withSubscription (subscribe: 'model -> Sub<'msg>) (program: Program<'arg, 'model, 'msg>) = { program with Subscribe = subscribe }
93111

112+
//TODO In what scenario would I want to use this?
94113
/// Map existing subscription to external source of events.
95114
let mapSubscription map (program: Program<'arg, 'model, 'msg>) =
96115
{ program with

0 commit comments

Comments
 (0)