Questions tagged [reducers]

Refers to reducers in the mapreduce framework. Mappers split up a large problem and solve parts of it in parallel. Reducers collect and summarize the output of a map method.

Reference: https://en.wikipedia.org/wiki/MapReduce

819 questions
7
votes
1 answer

Combine Reducer without Redux

I have an application without redux, I handle the global state with hooks and the hook useReducer + context. I have 1 useReducer which makes like a Redux store. But to do this I can only send 1 reducer. In that reducer I have all the logic of the…
7
votes
2 answers

ngrx : how the reducers function are invoked, when it is invoked?

I am trying my hands on ngrx library for managing the state of my application. I have gone through many ngrx documents and git pages. I understand that there are three important concept: Store Reducer and Action Store is the single source of data…
Ritesh Waghela
  • 3,474
  • 2
  • 19
  • 25
7
votes
2 answers

Best way to update related state fields with split reducers?

I'm trying to work out the ideal way to update several top level fields on my state tree while still maintaining split reducers. Here's a simple solution that I've come up with. var state = { fileOrder: [0], files: { 0:{ id: 0, …
Gary
  • 634
  • 6
  • 10
7
votes
1 answer

Clojure reducers library - folding with max

I'm trying to convert the following example to the new Clojure 1.5 reducers library: (reduce max (map inc (range 10))) ;=> 10 When I change it- I get the following error: (r/fold max (r/map inc (range 10))) ;ArityException Wrong number of args…
hawkeye
  • 34,745
  • 30
  • 150
  • 304
6
votes
1 answer

Axios response interceptor with combination with redux reducer

import React from "react"; import axios from "axios"; import {push} from "react-router-redux"; import {actionTypes} from "../Patient/actions"; import {put, call} from "redux-saga/effects"; import {updatePermissionsAction} from…
Benno
  • 289
  • 1
  • 3
  • 10
6
votes
2 answers

Redux nested reducers or normalize state?

I'm making a form component with React, and want to store the form(s) and field(s) state with Redux. So I have a form reducer and a formField reducer. I first followed my gut feeling and tried nesting the formField reducer in the form reducer. This…
Kris
  • 824
  • 2
  • 12
  • 28
6
votes
1 answer

Why does this Clojure Reducers r/fold provide no perf benefit?

I'm wondering why the code below provides no speedup in the case of r/fold? Am I misunderstanding something about reducers? I'm running it on a pretty slow (although with 2 cores) Ubuntu 12.04 dev box, both through emacs and lein run, each with the…
Scott Klarenbach
  • 37,171
  • 15
  • 62
  • 91
6
votes
3 answers

Tuning clojure reducers library performance

Why is mapping/reducing with reducers library has worse performance than normal map/reduce? user=> (time (reduce + (map inc (range 100000000)))) "Elapsed time: 14412.627966 msecs" 5000000050000000 user=> (time (reduce + (r/map inc (range…
FUD
  • 5,114
  • 7
  • 39
  • 61
6
votes
2 answers

Testing multiple outputs with MRUnit

Is there a way to test a reduce class with MRUnit that uses MultipleOutputFormat to write to multiple output files?
David Parks
  • 30,789
  • 47
  • 185
  • 328
5
votes
1 answer

React context API- How i can dispatch an action from the useEffect hook?

In this project I'm using React.createContext() methode to manage the state. I can access to the state data by importing the Context.Consumer and using this consumer in the return methode of the class component(or functional component). See thie…
bilalo
  • 129
  • 1
  • 1
  • 7
5
votes
1 answer

useSelector causes multiple re-renders

When using react-devtools it tells me that the reason my root component re-renderd was because hooks changed? when I remove any useSelectors, my root component renders only once, when enabled it renders 6 times. what are some guesses as to why this…
lord_drgical
  • 143
  • 2
  • 8
5
votes
1 answer

I have built a global state redux like pattern with context and hooks. Is there a way to combine reducers?

I've built a global state provider context, and a reducer with the useReducer Hook. I'm realizing that combining multiple reducers like I would in redux is problematic. Is there a good way to do this? I have seen people importing combineReducers…
Dave Funk
  • 77
  • 8
5
votes
1 answer

Redux updating state in another reducer

Setup In my app I have students who are assigned homework. Each time a student is created I loop through current homework and update homework array for each student. My issue is when I create a homework. Not only does that homework have to be…
Bromox
  • 567
  • 2
  • 9
  • 29
5
votes
1 answer

React-redux Spread operator in reducer returning error "unexpected token"

I followed Dan Abramov's code at https://github.com/tayiorbeii/egghead.io_redux_course_notes/blob/master/08-Reducer_Composition_with_Arrays.md I am getting error message "Unexpected token at line 22" referring to the ...todo Didn't think it's to do…
A Allen
  • 273
  • 1
  • 4
  • 12
5
votes
1 answer

Why is pmap|reducers/map not using all cpu cores?

I'm trying to parse a file with a million lines, each line is a json string with some information about a book (author, contents etc). I'm using iota to load the file, as my program throws an OutOfMemoryError if I try to use slurp. I'm also using…
eugecm
  • 1,189
  • 8
  • 14
1 2
3
54 55