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

Feature request: Allow adding new times to a chimes-ch channel #39

Open
aneilbaboo opened this issue Nov 15, 2020 · 2 comments
Open

Feature request: Allow adding new times to a chimes-ch channel #39

aneilbaboo opened this issue Nov 15, 2020 · 2 comments
Assignees

Comments

@aneilbaboo
Copy link

I'd like to create a channel then put! new times into it, like so:

(def chimes (chimes-ch []))

(a/<!! (go-loop []
           (when-let [msg (<! chimes)]
             (prn "Chiming at:" msg)
             (recur))))

(put! [(.plusSeconds (Instant/now) 3) (.plusSeconds (Instant/now) 5)])
;; currently, I get:
;; Execution error (IllegalArgumentException) at clojure.core.async.impl.protocols/eval2088$fn$G (protocols.clj:18).
;; No implementation of method: :put! of protocol: #'clojure.core.async.impl.protocols/WritePort found for class: chime.core_async$chime_ch$reify__37328

But perhaps there is a way to do this already? (I tried passing a channel to the ch param of chimes-ch and putting times into it, but that didn't work either).

@jarohen
Copy link
Owner

jarohen commented Nov 26, 2020

Hey @aneilbaboo - thanks for getting in touch. At the moment we assume that the list of times is immutable, so there's no way to modify it after the initial call. Depending on how often you need to do this, you might consider cancelling the scheduler and restarting with a modified sequence of times?

@aneilbaboo
Copy link
Author

aneilbaboo commented Nov 26, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants