Thanks to visit codestin.com
Credit goes to Github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cmd.fs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ module Cmd =
[bind >> start]

module OfAsync =
[<Obsolete("Use `AsyncHelpers.start` instead")>]
#if FABLE_COMPILER
let start x = Timer.delay 1 (fun _ -> Async.StartImmediate x)
#else
Expand All @@ -130,19 +131,19 @@ module Cmd =
(arg: 'a)
(ofSuccess: _ -> 'msg)
(ofError: _ -> 'msg) : Cmd<'msg> =
OfAsyncWith.either start task arg ofSuccess ofError
OfAsyncWith.either AsyncHelpers.start task arg ofSuccess ofError

/// Command that will evaluate an async block and map the success
let inline perform (task: 'a -> Async<_>)
(arg: 'a)
(ofSuccess: _ -> 'msg) : Cmd<'msg> =
OfAsyncWith.perform start task arg ofSuccess
OfAsyncWith.perform AsyncHelpers.start task arg ofSuccess

/// Command that will evaluate an async block and map the error (of exception)
let inline attempt (task: 'a -> Async<_>)
(arg: 'a)
(ofError: _ -> 'msg) : Cmd<'msg> =
OfAsyncWith.attempt start task arg ofError
OfAsyncWith.attempt AsyncHelpers.start task arg ofError

module OfAsyncImmediate =
/// Command that will evaluate an async block and map the result
Expand Down Expand Up @@ -224,4 +225,3 @@ module Cmd =
/// Command to issue a specific message
let inline ofMsg (msg:'msg) : Cmd<'msg> =
[fun dispatch -> dispatch msg]

7 changes: 7 additions & 0 deletions src/prelude.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ module internal Timer =
t.Enabled <- true
t.Start()
#endif

module AsyncHelpers =
#if FABLE_COMPILER
let start x = Timer.delay 1 (fun _ -> Async.StartImmediate x)
#else
let inline start x = Async.Start x
#endif
3 changes: 3 additions & 0 deletions websharper/prelude.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ module internal Array =
module internal Log =
let onError (text: string, ex: exn) = Console.Error (text,ex)
let toConsole(text: string, o: #obj) = Console.Log(text,o)

module AsyncHelpers =
let inline start x = Async.Start x
Loading