3 ms·
I put together a transducer in JavaScript with the intent to simplify Redux/flux architected front-ends. Rather than have synthetic actions that trigger reducti
by javajosh 3y ago
I put together a transducer in JavaScript with the intent to simplify Redux/flux architected front-ends. Rather than have synthetic actions that trigger reduction, I allow the caller to simply add objects directly into the store, and rely on them being combined in a useful way. And rather than leave it purely at dead data, I allow you to add functions, too, such that once added they can handle subsequent input. My `combine()` is a recursive `Object.assign()` plus reification of function calls: https://simpatico.io/combine2 https://simpatico.io/combine2. It's that second part that makes it a transducer.
This work predates the term "transducer" and I was happy to see Rich Hickey defining it, so I use the term retroactively.
Note that I don't see much use for transducers as a general programming technique. This one use is very specific, but I have never before or since needed one.
- vanderZwan 3y ago> This work predates the term "transducer" and I was happy to see Rich Hickey defining it IIRC Hickey did not define this term (nor claimed to have done so), he found it in existing compsci research papers that approached them from a mathematical proof angle and realized they solved a problem he needed to solve (basically not allocating intermediate collections and doing wasteful work on parts of the data that will be immediately discarded). I think one of the authors of the papers he cited even gave a talk at a Clojure conference once.
- eyelidlessness 3y agoFYI: I was curious and clicked your link, but it fully reloads the page every 2-3 seconds so I had to bail (iOS Safari if that helps)
- javajosh 3y agoThanks for the feedback, fixed. I like to use a simple method to speed up my BTD loop when doing webapp work, which is to add a `meta refresh` tag. But that's inappropriate for deployment. Note that my site is very strict about 3rd party content (none is allowed), and about privacy (the only log is in a tmux buffer), so there's no reason for this behavior other than my forgetfulness.