Comments (7)
Yeah, exactly & thanks to you, sir! Regarding multiple dispatches, I also added support for each individual interceptor to have the option to declare multiple side effects of same type:
https://github.com/thi-ng/umbrella/blob/master/packages/atom/src/event-bus.ts#L269
from umbrella.
Hey, sorry just briefly... I already noticed this too and the current lack of getting a handle on the bus itself from a handler is an oversight of my possibly too speedy refactoring last night. My original solution which I used in existing projects was to have an InterceptorContext, a kind of accumulator object into which handlers would not just add their side effects, but which also allows access to other bindings (like the bus, or other services). I got rid of this last night after reading about & liking redux's approach to just return values (instead of assigning them to the accumulator), but I think I might do a U-turn on this again... also still have to read about Citrus... so many links, so little time ;) Thanks, for these pointers though!
You also correctly observed that the way the "addCounter" effect in the demo is defined from within the app()
was exactly for that reason. I like your FX_DISPATCH_ASYNC
idea too. You can try it out first by just adding it as effect in "userland". Might be completely sufficient. If you feel like doing PR, by all means! Thanks
from umbrella.
So I just had a quick go at this and was wondering what your thoughts are :)
New demo: http://demo.thi.ng/umbrella/async-effect/
Source: https://github.com/thi-ng/umbrella/blob/master/examples/async-effect/src/index.ts
from umbrella.
@allforabit i hope you don't mind, but since i've already got the demo and done some more manual testing and updating other smaller things, I'll cut another release with this promise based version of the FX_DISPATCH_ASYNC
from the demo. Hope you didn't start working the PR for this yet...
from umbrella.
Related, I also updated the SideEffect
type sig to accept the EventBus
as optional argument for other use cases where this is needed/useful (e.g. see the addCounter
effect from the earlier demo). This still keeps the event handlers nicely pure, but allows effects to take more control.
from umbrella.
That's absolutely perfect. It's much nicer to do the normal dispatch along with an async dispatch as it's not nearly as nested this way. I was thinking that it'd be good to pass in the dispatch function to the effect handlers but it's probably the most flexible way is to pass in the full event bus. I can envisage standard effect handlers for channels and the likes, that could do multiple dispatches as new values come in. This would work nicely for socket connections for instance. Brilliant stuff, thanks very much for that!
from umbrella.
I believe it's safe to close this issue for now...
from umbrella.
Related Issues (20)
- [geom] `withAttribs(path, {})` closes the path HOT 3
- [vectors] Vec2 missing x and y coordinate HOT 3
- [shader-ast] Bitwise shift operation HOT 3
- [shader-ast] Unsigned integer vector arithmetic HOT 1
- [shader-ast] Dependency for ternary operators, while and for loop HOT 1
- [shader-ast] Array texture types are missing HOT 1
- [shader-ast] Missing matrix types HOT 1
- [shader-ast] Better design for `defn` with anonymous qualified arguments HOT 7
- [malloc] Multi-threaded allocations HOT 4
- Prototype Pollution vulnerability affecting @thi.ng/paths, versions <=5.1.62 HOT 7
- [hiccup-canvas] "packedPolyline" needs separate implementation or packedPoly needs to accept stride options?
- [color] ? [binary] Comparison with -0 using the "===" operator will also match 0 [equals-negative-zero] HOT 2
- RDMS based on rstream-query HOT 1
- [examples] Issue running the examples (failed to resolve entry for package) HOT 3
- [hiccup-svg] hiccup-svg's attributes don't seem to handle rstream HOT 7
- [rstream] error when using skypack build HOT 5
- [geom-accel] SpatialGrid2 hangs runtime when using `set` method HOT 3
- Polygons with holes? HOT 8
- [shader-ast] "Building a shader graph editor (WebGL, shader AST transpiler, UI)" HOT 2
- [rdom] Issue understanding $klist HOT 4
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 umbrella.