Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
continious functions in javascript

I'm learning redux and in this piece of code section there is a continuous function to pass the arguments. I couldn't understand the logic behinds that because i'm the PHP developer originally and it's unusual there. would you please explain and simplify that for me?

Here is my selector:

export const personBugs = userId => createSelector(
    state => state.entities.bugs,
    bugs => bugs.filter(bug => bug.userId === userId )
)

And here is my dispatch:

console.log(bugsActions.personBugs(1)(store.getState()));
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It's called a curry function or currying, this is when you want to provide one argument and at a later time provide another argument.

I am not sure why a selector is on your actions object but I'm sure that is a mistake. A selector is usually used in components to get data that the component needs but can also be used in middleware to get state info.

Here is an example of how a selector can be used in a component:

const PersonBugs = React.memo(function PersonBugs({
  personId,
}) {
  //here is a way to use the curry
  const bugs = useSelector(personBugs(personId));
  //if this wasn't a curry you have to do
  // const bugs = useSelector((state) =>
  //   personBugs(personId, state)
  // );
  //you could also not memoize the selector if you needed to
});

More information about selectors can be found here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!