How to pass arguments into Redux middleware?How do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How do I include a JavaScript file in another JavaScript file?How to check whether a string contains a substring in JavaScript?How do I pass command line arguments to a Node.js program?How do I remove a particular element from an array in JavaScript?Why use Redux over Facebook Flux?Why do we need middleware for async flow in Redux?

Is an easily guessed plot twist a good plot twist?

How can I show that the speed of light in vacuum is the same in all reference frames?

My current job follows "worst practices". How can I talk about my experience in an interview without giving off red flags?

Can't understand how static works exactly

Why can't a country print its own money to spend it only abroad?

Strange LED behavior: Why is there a voltage over the LED with only one wire connected to it?

Why did modems have speakers?

Is there a way to shorten this while condition?

Found old paper shares of Motorola Inc that has since been broken up

Considerations when providing money to one child now, and the other later?

Is the apartment I want to rent a scam?

Why does the salt in the oceans not sink to the bottom?

What is the best word describing the nature of expiring in a short amount of time, connoting "losing public attention"?

What is an expert set in the fonts field?

What kind of curve (or model) should I fit to my percentage data?

What gave NASA the confidence for a translunar injection in Apollo 8?

Is it OK to accept a job opportunity while planning on not taking it?

Can someone explain the English 'W' sound?

Does Impedance Matching Imply any Practical RF Transmitter Must Waste >=50% of Energy?

Are gangsters hired to attack people at a train station classified as a terrorist attack?

Xcode 10.3 Installation

Company requiring me to let them review research from before I was hired

Are rockets faster than airplanes?

Pgfplots fillbetween and Tikz shade



How to pass arguments into Redux middleware?


How do JavaScript closures work?How do I check if an element is hidden in jQuery?How do I remove a property from a JavaScript object?How do I redirect to another webpage?How do I include a JavaScript file in another JavaScript file?How to check whether a string contains a substring in JavaScript?How do I pass command line arguments to a Node.js program?How do I remove a particular element from an array in JavaScript?Why use Redux over Facebook Flux?Why do we need middleware for async flow in Redux?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I want to pass an argument into a custom Redux middleware.
But I don't know how to use the argument inside the custom middleware.



Example:



import createStore, applyMiddleware from 'redux';
import reducers from './reducers';

const customMiddleWare = store => next => action =>
// how to use argument here?
;

const middlewares = [customMiddleWare(argument)];

const store = createStore(
reducers,
applyMiddleware(...middlewares)
);









share|improve this question
























  • What specifically are you trying to accomplish? You're already passing an argument into customMiddleWare but it's not the one you think you are. Not sure what your actual use-case is, but in general, that's not how middleware is structured.

    – Dave Newton
    Mar 26 at 14:32











  • @DaveNewton You're right, I updated the question.

    – soroush chehresa
    Mar 26 at 14:41

















0















I want to pass an argument into a custom Redux middleware.
But I don't know how to use the argument inside the custom middleware.



Example:



import createStore, applyMiddleware from 'redux';
import reducers from './reducers';

const customMiddleWare = store => next => action =>
// how to use argument here?
;

const middlewares = [customMiddleWare(argument)];

const store = createStore(
reducers,
applyMiddleware(...middlewares)
);









share|improve this question
























  • What specifically are you trying to accomplish? You're already passing an argument into customMiddleWare but it's not the one you think you are. Not sure what your actual use-case is, but in general, that's not how middleware is structured.

    – Dave Newton
    Mar 26 at 14:32











  • @DaveNewton You're right, I updated the question.

    – soroush chehresa
    Mar 26 at 14:41













0












0








0








I want to pass an argument into a custom Redux middleware.
But I don't know how to use the argument inside the custom middleware.



Example:



import createStore, applyMiddleware from 'redux';
import reducers from './reducers';

const customMiddleWare = store => next => action =>
// how to use argument here?
;

const middlewares = [customMiddleWare(argument)];

const store = createStore(
reducers,
applyMiddleware(...middlewares)
);









share|improve this question
















I want to pass an argument into a custom Redux middleware.
But I don't know how to use the argument inside the custom middleware.



Example:



import createStore, applyMiddleware from 'redux';
import reducers from './reducers';

const customMiddleWare = store => next => action =>
// how to use argument here?
;

const middlewares = [customMiddleWare(argument)];

const store = createStore(
reducers,
applyMiddleware(...middlewares)
);






javascript reactjs redux react-redux redux-middleware






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 14:39







soroush chehresa

















asked Mar 26 at 14:29









soroush chehresasoroush chehresa

1,9311 gold badge5 silver badges18 bronze badges




1,9311 gold badge5 silver badges18 bronze badges












  • What specifically are you trying to accomplish? You're already passing an argument into customMiddleWare but it's not the one you think you are. Not sure what your actual use-case is, but in general, that's not how middleware is structured.

    – Dave Newton
    Mar 26 at 14:32











  • @DaveNewton You're right, I updated the question.

    – soroush chehresa
    Mar 26 at 14:41

















  • What specifically are you trying to accomplish? You're already passing an argument into customMiddleWare but it's not the one you think you are. Not sure what your actual use-case is, but in general, that's not how middleware is structured.

    – Dave Newton
    Mar 26 at 14:32











  • @DaveNewton You're right, I updated the question.

    – soroush chehresa
    Mar 26 at 14:41
















What specifically are you trying to accomplish? You're already passing an argument into customMiddleWare but it's not the one you think you are. Not sure what your actual use-case is, but in general, that's not how middleware is structured.

– Dave Newton
Mar 26 at 14:32





What specifically are you trying to accomplish? You're already passing an argument into customMiddleWare but it's not the one you think you are. Not sure what your actual use-case is, but in general, that's not how middleware is structured.

– Dave Newton
Mar 26 at 14:32













@DaveNewton You're right, I updated the question.

– soroush chehresa
Mar 26 at 14:41





@DaveNewton You're right, I updated the question.

– soroush chehresa
Mar 26 at 14:41












1 Answer
1






active

oldest

votes


















2














As middlewares are functions you can make a wrapper function that will take your argument and return your middleware function which will have access to the provided argument.



Example:



const middlewareWrapper = customArgument => store => next => action =>
console.log(customArgument);
}

const middlewares = [middlewareWrapper(argument)];

const store = createStore(
reducers,
applyMiddleware(...middlewares)
);





share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55359630%2fhow-to-pass-arguments-into-redux-middleware%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    As middlewares are functions you can make a wrapper function that will take your argument and return your middleware function which will have access to the provided argument.



    Example:



    const middlewareWrapper = customArgument => store => next => action =>
    console.log(customArgument);
    }

    const middlewares = [middlewareWrapper(argument)];

    const store = createStore(
    reducers,
    applyMiddleware(...middlewares)
    );





    share|improve this answer





























      2














      As middlewares are functions you can make a wrapper function that will take your argument and return your middleware function which will have access to the provided argument.



      Example:



      const middlewareWrapper = customArgument => store => next => action =>
      console.log(customArgument);
      }

      const middlewares = [middlewareWrapper(argument)];

      const store = createStore(
      reducers,
      applyMiddleware(...middlewares)
      );





      share|improve this answer



























        2












        2








        2







        As middlewares are functions you can make a wrapper function that will take your argument and return your middleware function which will have access to the provided argument.



        Example:



        const middlewareWrapper = customArgument => store => next => action =>
        console.log(customArgument);
        }

        const middlewares = [middlewareWrapper(argument)];

        const store = createStore(
        reducers,
        applyMiddleware(...middlewares)
        );





        share|improve this answer















        As middlewares are functions you can make a wrapper function that will take your argument and return your middleware function which will have access to the provided argument.



        Example:



        const middlewareWrapper = customArgument => store => next => action =>
        console.log(customArgument);
        }

        const middlewares = [middlewareWrapper(argument)];

        const store = createStore(
        reducers,
        applyMiddleware(...middlewares)
        );






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 26 at 14:59









        soroush chehresa

        1,9311 gold badge5 silver badges18 bronze badges




        1,9311 gold badge5 silver badges18 bronze badges










        answered Mar 26 at 14:46









        shemekhshemekh

        8110 bronze badges




        8110 bronze badges


















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55359630%2fhow-to-pass-arguments-into-redux-middleware%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript