Skip to content

Commit e47a5c3

Browse files
committed
TODO added questions
1 parent 7339a57 commit e47a5c3

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/Fabulous/Cmd.fs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ module Cmd =
163163

164164
[ bind >> start ]
165165

166+
(* TODO this doesn't use Async.Catch - is that intended?
167+
Is this misplaced here or should that be documented?
168+
Or is there some magic involved that turns an exn into None? *)
166169
/// Command that will evaluate an async block and map the success
167170
let performOption (start: Async<unit> -> unit) (task: 'a -> Async<_ option>) (arg: 'a) (ofSuccess: _ -> 'msg) : Cmd<'msg> =
168171
let bind dispatch =
@@ -176,6 +179,12 @@ module Cmd =
176179

177180
[ bind >> start ]
178181

182+
//TODO Feel free to trim the fat from this description.
183+
(* TODO There are some caveats and warnings against using Async.Start in the chapter behind that first link.
184+
Do they need to be reflected here? *)
185+
(* TODO When would I use this instead of OfAsyncImmediate?
186+
Why would I not always use OfAsyncImmediate? Are there some typical use cases?
187+
How can we help devs decide which sub-module to use? *)
179188
/// For building Commands from Async functions queued to be run in the background, started on a thread pool thread using Async.Start.
180189
/// Suitable for long-running or CPU-bound computations where you want to free up the UI thread to remain responsive to do other work.
181190
/// See https://learn.microsoft.com/en-us/dotnet/fsharp/tutorials/async#asyncstart
@@ -202,6 +211,10 @@ module Cmd =
202211
let inline msgOption (task: Async<'msg option>) =
203212
OfAsyncWith.performOption Async.Start (fun () -> task) () id
204213

214+
(* TODO I took parts of this description from the link source,
215+
suggesting this has an effect on async ops updating the UI.
216+
But using Cmd.OfAsync seems to work just fine for them as well. So why use this then?
217+
Is there an example out there demonstrating the effect - or can one be made up? *)
205218
/// For building Commands from Async functions started immediately on the current operating system thread
206219
/// using Async.StartImmediate. This is helpful if you need to update something on the calling thread during the computation.
207220
/// For example if an asynchronous computation must update a UI (such as updating a progress bar).

src/Fabulous/Program.fs

Lines changed: 7 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>
@@ -112,6 +118,7 @@ module Program =
112118
/// </summary>
113119
let withSubscription (subscribe: 'model -> Sub<'msg>) (program: Program<'arg, 'model, 'msg>) = { program with Subscribe = subscribe }
114120

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

src/Fabulous/Sub.fs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ namespace Fabulous
22

33
open System
44

5+
//TODO if this is a Subscription ID...
56
/// Subscription ID, alias for string list
67
type SubId = string list
78

9+
//TODO ...then is this not rather the Subscription...
810
/// Starts a subscription by supplying a Dispatch{'msg}
911
/// which it may use to start dispatching messages similar to Effect{'msg}.
1012
/// Returns an IDisposable to stop it.
1113
type Subscribe<'msg> = Dispatch<'msg> -> IDisposable
1214

15+
//TODO ...and this an ID'd Subscription list?
1316
/// Subscription - Generates new messages when running
1417
type Sub<'msg> = (SubId * Subscribe<'msg>) list
1518

@@ -21,6 +24,7 @@ module Sub =
2124
/// Aggregate multiple subscriptions
2225
let batch (subs: Sub<'msg> list) : Sub<'msg> = List.concat subs
2326

27+
//TODO How does this relate to Program.mapSubscription ?
2428
/// When emitting the message, map to another type.
2529
/// To avoid ID conflicts with other components, scope SubIds with a prefix.
2630
let map (idPrefix: string) (f: 'a -> 'msg) (sub: Sub<'a>) : Sub<'msg> =

0 commit comments

Comments
 (0)