Skip to content

Commit

Permalink
Readme update with new examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanrobinson committed Jan 3, 2024
1 parent 1a90cb6 commit 22b6f27
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,38 @@ Clojure wrapper for the [Awaitility](http://www.awaitility.org/) Java library.
(fn [] (>= (System/currentTimeMillis) end-time)))) ; function that will eventually return true
```

### `at-least` parameter

```clojure
;; Example of at-least parameter
(let [start-time (System/currentTimeMillis)
end-time (+ start-time 200)]

(wait-for {:at-least [2 :seconds]} ; in this case we don't wait long enough
(fn [] (>= (System/currentTimeMillis) end-time))))

; this returns -> org.awaitility.core.ConditionTimeoutException: Condition was evaluated in 200
; milliseconds which is earlier than expected minimum timeout 500 milliseconds
```
### Poll intervals
```clojure
;; can do either:
(let [start-time (System/currentTimeMillis)
end-time (+ start-time 200)]

(wait-for {:poll-interval [50 :milliseconds]} ; 50, 100, 150... milliseconds
(fn [] (>= (System/currentTimeMillis) end-time))))

;; or
(:import [org.awaitility.pollinterval FibonacciPollInterval])

(let [start-time (System/currentTimeMillis)
end-time (+ start-time 200)]

(wait-for {:poll-interval (FibonacciPollInterval.)} ; 1, 1, 2, 3, 5, 8... milliseconds
(fn [] (>= (System/currentTimeMillis) end-time))))
```

## License

Copyright © 2024 Jordan Robinson
Expand Down

0 comments on commit 22b6f27

Please sign in to comment.