8000 Multiple invocations of `on-finished` · Issue #36 · jarohen/chime · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Multiple invocations of on-finished #36
Closed
@dazld

Description

@dazld

I'm not sure what the correct behaviour should be here, but might be worth thinking about a little.

Given the following code:

(let [now (Instant/now)
        chiming (chime/chime-at [(.plusSeconds now 1)
                                 (.plusSeconds now 3)]
                                (fn [time]
                                  (prn :chime (str time)))
                                {:on-finished #(prn :done)})]
    (Thread/sleep 4000)
    (.close chiming))

... we can see that on-finished is called twice:

:chime "2020-09-07T13:52:33.193745Z"
:chime "2020-09-07T13:52:35.193745Z"
:done
:done

This was surprising to me - perhaps on-finished should have an invariant that it is only ever called once?

Another option is that perhaps the value which on-finished evaluates to should be delivered to the invocation of close, meaning the fn can be evaluated once, but value delivered to multiple places...? Seems like this could be useful.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0