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;
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
add a comment |
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
What specifically are you trying to accomplish? You're already passing an argument intocustomMiddleWare
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
add a comment |
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
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
javascript reactjs redux react-redux redux-middleware
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 intocustomMiddleWare
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
add a comment |
What specifically are you trying to accomplish? You're already passing an argument intocustomMiddleWare
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
add a comment |
1 Answer
1
active
oldest
votes
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)
);
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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)
);
add a comment |
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)
);
add a comment |
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)
);
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)
);
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
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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