Gibt es eine elegante Möglichkeit, einen laufenden Go-Block zu stoppen?Wie Stop Block in ClojureScript/core.async zu stoppen?
(ohne ein Flag Einbringen und verschmutzen den Code mit Kontrollen/branches)
(ns example
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [cljs.core.async :refer [<! timeout]]))
(defn some-long-task []
(go
(println "entering")
; some complex long-running task (e.g. fetching something via network)
(<! (timeout 1000))
(<! (timeout 1000))
(<! (timeout 1000))
(<! (timeout 1000))
(println "leaving")))
; run the task
(def task (some-long-task))
; later, realize we no longer need the result and want to cancel it
; (stop! task)
'(nah! Aufgabe)' vielleicht? - Google erstes Ergebnis. – birdspider