Create a Buffer to Pair Values Together with Zip

InstructorJohn Lindquist

Share this video with your friends

Send Tweet

Functions returning functions returning functions can begin to look a bit unwieldy. The arrow function has helped the syntax a lot, but maybe using a curry utility function to combine all the arguments into a single function will help your syntax look a little cleaner. Currying isn't necessary for our pattern, but you'll definitely see it used in many patterns involving functions returning functions and maybe you'll grow to love it.

felikf
~ 4 years ago

Notes: broadcaster - function that accepts listener operator - function that accepts broadcaster(s) and returns another broadcaster

const map = curry((broadcaster, mapper, listener) => {
    return broadcaster(value => {
        listener(mapper(value))
    })
})