Skip to content

Commit 9edb16b

Browse files
committed
Update Fantomas and format code
1 parent 58825f5 commit 9edb16b

4 files changed

Lines changed: 26 additions & 26 deletions

File tree

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"fantomas": {
6-
"version": "5.2.0",
6+
"version": "6.2.3",
77
"commands": [
88
"fantomas"
99
]

src/Fabulous.Tests/CmdTests.fs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,26 @@ module CmdTestsHelper =
99
let execute dispatch (cmd: Cmd<'msg>) =
1010
for sub in cmd do
1111
sub dispatch
12-
12+
1313
[<TestFixture>]
1414
type ``Cmd tests``() =
1515
[<Test>]
1616
member _.``Cmd.debounce only dispatch the last message``() =
1717
async {
1818
let mutable actualValue = None
19+
1920
let dispatch msg =
2021
if actualValue.IsNone then
2122
actualValue <- Some msg
22-
23+
2324
let triggerCmd = Cmd.debounce 100 NewValue
24-
25+
2526
triggerCmd 1 |> CmdTestsHelper.execute dispatch
2627
do! Async.Sleep 50
2728
triggerCmd 2 |> CmdTestsHelper.execute dispatch
2829
do! Async.Sleep 75
2930
triggerCmd 3 |> CmdTestsHelper.execute dispatch
3031
do! Async.Sleep 125
31-
32+
3233
Assert.AreEqual(Some(NewValue 3), actualValue)
33-
}
34+
}

src/Fabulous/Builders.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ type WidgetBuilder<'msg, 'marker> =
3838
DebugName = $"{typeof<'marker>.Name}<{typeof<'msg>.Name}>"
3939
#endif
4040
ScalarAttributes =
41-
match StackList.length &scalarAttributes with
42-
| 0us -> ValueNone
43-
| _ -> ValueSome(Array.sortInPlace (fun a -> a.Key) (StackList.toArray &scalarAttributes))
41+
match StackList.length &scalarAttributes with
42+
| 0us -> ValueNone
43+
| _ -> ValueSome(Array.sortInPlace (fun a -> a.Key) (StackList.toArray &scalarAttributes))
4444

4545
WidgetAttributes = ValueOption.map (Array.sortInPlace(fun a -> a.Key)) widgetAttributes
4646

src/Fabulous/Cmd.fs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,23 @@ module Cmd =
105105
dispatch(failure ex)
106106
}
107107
|> ignore ]
108-
108+
109109
/// Command to issue a message if no other message has been issued within the specified timeout
110-
let debounce (timeout: int) (fn: 'value -> 'msg): 'value -> Cmd<'msg> =
110+
let debounce (timeout: int) (fn: 'value -> 'msg) : 'value -> Cmd<'msg> =
111111
let mutable cts: CancellationTokenSource = null
112-
112+
113113
fun (value: 'value) ->
114114
[ fun dispatch ->
115-
if cts <> null then
116-
cts.Cancel()
117-
cts.Dispose()
118-
119-
cts <- new CancellationTokenSource()
120-
121-
Async.Start(
122-
async {
123-
do! Async.Sleep(timeout)
124-
dispatch (fn value)
125-
},
126-
cts.Token
127-
)
128-
]
115+
if cts <> null then
116+
cts.Cancel()
117+
cts.Dispose()
118+
119+
cts <- new CancellationTokenSource()
120+
121+
Async.Start(
122+
async {
123+
do! Async.Sleep(timeout)
124+
dispatch(fn value)
125+
},
126+
cts.Token
127+
) ]

0 commit comments

Comments
 (0)