Back
close-with (clj)
(source)macro
(close-with proc x)
Take a procedure `proc`, an object `x`, return `x`. When the map is
closed `(proc x)` will be called. Will have no effect out of a
closeable map.
Some classes do not implement `java.lang.AutoCloseable` but present
some similar method. For example instances of
`java.util.concurrent.ExecutorService` can't be closed but they can
be shut down, which achieves a similar outcome. This convenience
macro allows you to express it this way:
``` clojure
(closeable-map/close-with (memfn ^ExecutorService .shutdown) my-service)
;; => my-service
```