Comments (2)
It seems to work properly if I wrap the inner flow in a task:
(require '[missionary.core :as ms])
(def cancel
(do
(when (bound? (resolve 'cancel))
(cancel))
(def mbx (ms/mbx))
(let [sub-flow (fn [next]
(ms/reduce
(constantly nil)
(ms/ap
(let [task-id (ms/?= (ms/seed next))]
(loop []
(println "RUNNING TASK" (ms/? (ms/sleep 1000 task-id)))
(recur))))))
mbx-flow (ms/ap
(->> (repeat mbx)
ms/seed
ms/?>
ms/?))
flow (ms/ap
(let [next (ms/?< mbx-flow)]
(try
(ms/? (sub-flow next))
(catch Exception ex
(ms/?> ms/none)))))
task (->> (ms/reduce (constantly nil) flow))]
(task println println))))
(cancel)
(mbx [1 2 3]) ;; [1]
(mbx [4 5 6]) ;; [2]
from missionary.
I would expect that running [2] would stop printing 1,2,3 and instead start printing only 4,5,6. However, currently it continues printing 1,2,3 in addition to 4,5,6.
You're right, switching should cancel all child branches, including concurrent ones.
from missionary.
Related Issues (20)
- Performance warning - case has int tests, but tested expression is not primitive.
- Compiler Exception on Clojure 1.11.1 - No matching clause: :static-field HOT 2
- zip doesn't terminate properly HOT 3
- group-by consumers must terminate immediately on input crash HOT 6
- Large dependency: missionary dependency grows uber jar by 26 MiB
- Cannot set properties of undefined (setting 'parent') HOT 2
- Cannot read properties of null (reading 'parallelism')
- nullpointerexception with subscribe HOT 6
- `m/sleep` does not terminate after exception HOT 1
- task succeeds on cancel when task body is wrapped in a try/catch HOT 10
- missionary.Cancelled not thrown HOT 6
- `m/mbx` on post can return non-nil value, the docs say otherwise
- `ap` bug
- Cancel in example for basic walkthrough doesn't work HOT 3
- watch can discard latest value
- Hello task example prints only Hello with Clojure repl HOT 4
- generalize `signal` to any semigroup HOT 1
- `observe` - on JVM, consider parking the caller thread instead of throwing when pipeline is busy HOT 2
- make `ap` switch consistent with `cp` HOT 1
- `stream` double subscriptions - document correct pattern + investigate bug
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from missionary.