summaryrefslogtreecommitdiff
path: root/viz.js/promise/promise.mli
blob: 26831c42975711ff8eced671ae5dfdf490102f1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
type ('a, 'b) promise

type 'a resolve = 'a -> unit

type 'a reject = 'a -> unit

val is_supported : unit -> bool

val make : ('a resolve -> 'b reject -> unit) -> ('a, 'b) promise

val resolve : 'a -> ('a, 'b) promise

val reject : 'b -> ('a, 'b) promise

val then_bind :
  on_fulfilled:('a -> ('c ,'b) promise) ->
  ?on_rejected:('b -> ('c, 'b) promise) ->
  ('a, 'b) promise ->
  ('c, 'b) promise

val then_map :
  on_fulfilled:('a -> 'c) ->
  ?on_rejected:('b -> 'd) ->
  ('a, 'b) promise ->
  ('c, 'd) promise

val catch_bind :
  on_rejected:('b -> ('a, 'b) promise) ->
  ('a, 'b) promise ->
  ('a, 'b) promise

val catch_map :
  on_rejected:('b -> 'a) ->
  ('a, 'b) promise ->
  ('a, 'b) promise

val then_final :
  on_fulfilled:('a -> unit) ->
  on_rejected:('b -> unit) ->
  ('a, 'b) promise ->
  unit

val all : (('a, 'b) promise) array -> ('a array, 'b) promise

val race : (('a, 'b) promise) array -> ('a, 'b) promise

module Infix : sig
  val (>>=) : ('a, 'b) promise -> ('a -> ('c ,'b) promise) -> ('c, 'b) promise
  val (>|=) : ('a, 'b) promise -> ('a -> 'c) -> ('c, 'b) promise

  val (>>~) : ('a, 'b) promise -> ('b -> ('a, 'b) promise) -> ('a, 'b) promise
  val (>|~) : ('a, 'b) promise -> ('b -> 'a) -> ('a, 'b) promise

  val (>||) : ('a, 'b) promise -> ('a -> unit) * ('b -> unit) -> unit
end