File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
src/FsToolkit.ErrorHandling.TaskResult Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ ## Task.ignore
2
+
3
+ Namespace: ` FsToolkit.ErrorHandling `
4
+
5
+ Function Signature:
6
+
7
+ ``` fsharp
8
+ Task<'a> -> Task<unit>
9
+ ```
10
+
11
+ This is a shortcut for ` Task.map ignore ` .
12
+
13
+ ## Examples
14
+
15
+ ### Example 1
16
+
17
+ ``` fsharp
18
+ let savePost : CreatePostRequest -> Task<PostId, exn>
19
+ ```
20
+
21
+ We can call this with the ` do! ` syntax inside a computation expression using ` Task.ignore ` as below:
22
+
23
+ ``` fsharp
24
+ let makePost = task {
25
+ do! savePost createPostRequest |> Task.ignore
26
+ }
27
+ ```
Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ module Task =
45
45
46
46
let inline map3 ( [<InlineIfLambda>] f ) x y z = apply ( map2 f x y) z
47
47
48
+ /// Allows us to call `do!` syntax inside a computation expression
49
+ let inline ignore ( x : Task < 'a >) =
50
+ x
51
+ |> map ignore
48
52
49
53
/// Takes two tasks and returns a tuple of the pair
50
54
let zip ( a1 : Task < _ >) ( a2 : Task < _ >) =
You can’t perform that action at this time.
0 commit comments