How should functional programming be understood?

recently looking at the react-related technology stack, I feel that a lot of things seem a little laborious.
such as the related use of redux-saga, as follows:

import { createStore, combineReducers, applyMiddleware } from "redux";
import userNameReducer from "../username/reducer.js";
import createSagaMiddleware from "redux-saga";       
import rootSaga from "./saga.js";                   

const sagaMiddleware = createSagaMiddleware()        // create/ sagaMiddleware

const reducerAll = {
    userNameReducer: userNameReducer
}


export const store = createStore(
    combineReducers({...reducerAll}), // fn()reducer
    window.devToolsExtension ? window.devToolsExtension() : undefined,    
    applyMiddleware(sagaMiddleware)                 // applyMiddlewaresagaMiddlewarecreateStorefnAfnA({},fnB(fnC))fn()
)

sagaMiddleware.run(rootSaga)                        // sagaMiddlewarerunrunrootSagafnA(fnB)

there are two problems:

    Why can"t createSagaMiddleware in
  1. import createSagaMiddleware from "redux-saga"; be used directly like deepClone () in import {deepClone} from" lodash";? Instead, you need to return the function to a new function in the form of fnA (fnB), and then use it.
  2. this kind of fnA ({}, fnB (fnC (fnD), {})) this way of writing looks so difficult to understand.

ask the bosses for advice.

Dec.20,2021

depends on what this module exports and what other modules need to use. To put it simply:
it exports a utility function, such as cloneDeep, which can be deconstructed and used directly.
it exports a function, but it actually uses the return value of this function, so you have to execute the function to get what you need.

for your second question, object-oriented thinking. A function is actually an object, just like an array, except that the function has its own unique method properties and implements a call method.

Menu