Skip to content

Commit

Permalink
Remove IState public API from CLJS
Browse files Browse the repository at this point in the history
  • Loading branch information
niwinz committed Oct 15, 2022
1 parent 60ebb40 commit 30ea837
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 29 deletions.
51 changes: 28 additions & 23 deletions src/promesa/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -101,29 +101,34 @@

;; Predicates

(defn resolved?
"Returns true if promise `p` is already fulfilled."
[p]
(pt/-resolved? p))

(defn rejected?
"Returns true if promise `p` is already rejected."
[p]
(pt/-rejected? p))

(defn pending?
"Returns true if promise `p` is stil pending."
[p]
(pt/-pending? p))

(defn extract
"Returns the current promise value."
[p]
(pt/-extract p))

(def done?
"Returns true if promise `p` is already done."
(complement pending?))
#?(:clj
(defn resolved?
"Returns true if promise `p` is already fulfilled."
[p]
(pt/-resolved? p)))

#?(:clj
(defn rejected?
"Returns true if promise `p` is already rejected."
[p]
(pt/-rejected? p)))

#?(:clj
(defn pending?
"Returns true if promise `p` is stil pending."
[p]
(pt/-pending? p)))

#?(:clj
(defn extract
"Returns the current promise value."
[p]
(pt/-extract p)))

#?(:clj
(def done?
"Returns true if promise `p` is already done."
(complement pending?)))

;; Chaining

Expand Down
13 changes: 7 additions & 6 deletions src/promesa/protocols.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
"Apply function to a computation identpendently if is failed or
successful; the return value is ignored."))

(defprotocol IState
"Additional state/introspection abstraction."
(-extract [_] "Extract the current value.")
(-resolved? [_] "Returns true if a promise is resolved.")
(-rejected? [_] "Returns true if a promise is rejected.")
(-pending? [_] "Retutns true if a promise is pending."))
#?(:clj
(defprotocol IState
"Additional state/introspection abstraction."
(-extract [_] "Extract the current value.")
(-resolved? [_] "Returns true if a promise is resolved.")
(-rejected? [_] "Returns true if a promise is rejected.")
(-pending? [_] "Retutns true if a promise is pending.")))

(defprotocol IPromiseFactory
"A promise constructor abstraction."
Expand Down

0 comments on commit 30ea837

Please sign in to comment.