Write Reducers for Different Data Types

InstructorPaul Frend

Share this video with your friends

Send Tweet

Now that we understand the problem transducers can help us with, it's time to define what they actually are. A Transducer is a combination of two concepts, a transform, and a reducer. Trans-Ducer. In this lesson we'll give a general overview of the reducer part of the puzzle.

Timothy
~ 7 years ago

an aside: Those inline /?/ logging things are cool. Is that a webstorm thing? Hmm wonder if I could implement that in sublime text?

Paul Binns
~ 7 years ago

What are you doing to automatically get the logging annotation in quokka? As in /*?*/

Paul Frendinstructor
~ 7 years ago

@timothy it's a plugin called quokka, but also has editor support for vs code and atom. It's pretty awesome for explorative coding and getting super fast feedback loops https://quokkajs.com/

Paul Frendinstructor
~ 7 years ago

@paul I've just got a webstorm live template for it with the string qc which expands on tab press

write qc, press tab -> /*?*/

If it appears more automatic than that it's probably due to the magic of editing :).

However, I've also recorded a macro which goes to end of line, writes qc and presses tab which works really well, but didn't use that in the videos.

Yvon
~ 6 years ago

Hi Paul, with quokka i have the error bellow ​​​​Quokka 'Untitled-3.js' (node: v9.3.0, babel: v6.26.3, plugins: jsdom-quokka-plugin)​​​​ SyntaxError: quokka.js: Unexpected token (60:8)  58 | const objReducer = (acc, obj) => {  59 | return { 

60 | ...acc,  | ^  61 | ...obj,  62 | }  63 | }  any idea?

Paul Frendinstructor
~ 6 years ago

Hi @Yvon, It's a bit hard to see the code snippet above, but my guess is that's due to babel not knowing how to handle the spread operator. Since you're using babel 6, you prob have to add this plugin: https://www.npmjs.com/package/babel-plugin-transform-object-rest-spread. You could also try using babel@7 instead, which supports this syntax by default I believe (with something like https://babeljs.io/docs/en/babel-preset-env )

Yvon
~ 6 years ago

Hi Paul, thanks a lot for the answer. I had to use babel@7. Great course by the way.

Tre' Codez
~ 5 years ago

Is that WallabyJS in your IDE?! :)