Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close-with doesn't work on Java objects #8

Open
piotr-yuxuan opened this issue Mar 27, 2022 · 4 comments
Open

close-with doesn't work on Java objects #8

piotr-yuxuan opened this issue Mar 27, 2022 · 4 comments
Labels
bug Something isn't working bug-resolved help wanted Extra attention is needed question Further information is requested

Comments

@piotr-yuxuan
Copy link
Owner

It uses ::fn meta and as such needs a Clojure object. The implementation should change so that it attach the fn to the map and not the object.

@piotr-yuxuan piotr-yuxuan added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Mar 27, 2022
@piotr-yuxuan
Copy link
Owner Author

I think it does qualify as a bug, but it's quite telling that nobody reported it ^_^ Another explanation is nobody actually tried to use ::fn.

@piotr-yuxuan
Copy link
Owner Author

Actually ::closeable-map/fn is more for custom close function, for example with reporting and so on. In such case indeed a custom function may be added in the metadata of the containing map. However, closeable-map may be taught to close any object instances by extending the ::closeable-map/close! method.

(import '(clojure.lang Atom))
(defmethod c/close! Atom [x] (reset! x nil))

(import '(clojure.core.async.impl.protocols Channel))
(defmethod c/close! Channel [x] (async/close! x))

This should be added as examples.

@piotr-yuxuan
Copy link
Owner Author

As long as Java objects are concerned, user can make use of the star pattern, that is to say a closeable* within a closeable-map*. In effect this does register this Java object in the metadata of the container.

@piotr-yuxuan
Copy link
Owner Author

I'm reluctant to change close-with. Very happy to hear a different opinion about it.

@piotr-yuxuan piotr-yuxuan added bug-resolved help wanted Extra attention is needed question Further information is requested and removed good first issue Good for newcomers help wanted Extra attention is needed labels Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bug-resolved help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant