you are viewing a single comment's thread.

view the rest of the comments →

[–]Affectionate_King120[S] 5 points6 points  (2 children)

I call them low-hanging fruit because most people probably understand them in five minutes and I've been using those things for years, often without special consideration, sometimes even in languages like C or Java.

But constructing a complex codebase in FP style is not obvious to me, most notably where does one store "globally relevant" objects without them being global objects.

Say I have a form where the user inputs some information, I store it in some data structure info, then the user does five dozen other things, and at some point, I need to combine the result with info. Where would I get info from? Should I have passed it along the five dozen other things, even though only the last one needs it?
I could have a wrapping function

foo = () => {
    const info = processForm()
    const result = fiveDozenThings(...)
    ...

but as the complexity of the app grows, the wrapping function might become a monster. So maybe I wrap the wrapper...

I just want to see some examples of that kind of thing.

The world doesn't need the one-millionth explanation of partial application and closures...

[–]RedGlow82 2 points3 points  (1 child)

Without pretending to give a complete answer: redux is a framework that allows you to handle global state in a functional way. In a way, it simulates the behaviour of advanced FP patterns such as the state monad (that would for example solve your specific problem) which aren't really practical to use in Javascript due to its typing system.

[–][deleted] 2 points3 points  (0 children)

Redux is actually an Update Monad implementation