---
  title: "Reducer-store"
  description: "Documented Methods"
  sections: 
    - 
      type: "markdown-section"
      content: "DataModel\n\nA page level storage which stores, registers, unregisters reducers for all the datamodel instances. There is only one\nreducer store available in a page. All the datamodel instances receive same instance of reducer store. DataModel\nout of the box provides handful of [reducers](reducer) which can be used as reducer funciton."
    - 
      type: "markdown-section"
      content: "### <a name=defaultReducer></a> defaultReducer(params) → {[ReducerStore](ReducerStore)}\n\nChanges the `defaultReducer` globally. For all the fields which does not have `defAggFn` mentioned in schema, the\nvalue of `defaultReducer` is used for aggregation."
    - 
      type: "markdown-section"
      content: "<p class=\"sub-header\">Parameters:</p>\n<table><thead><tr><td>Name</td><td>Type</td><td>Description</td></tr></thead>\n<tr>\n                <td class=\"param-name\">reducer</td>\n                <td><p>string</p> </td>\n                <td><p>name of the default reducer. It picks up the definition from store by doing name      lookup. If no name is found then it takes <code>sum</code> as the default reducer.</p> </td>\n            </tr></table>"
    - 
      type: "markdown-section"
      content: "<a name=ReducerStore></a><p class=\"sub-header\">Returns:</p>\n\n <span style=\"font-family: 'Source Code Pro';margin-left: 2%;\">ReducerStore:</span>instance of the singleton store in page."
    - 
      type: "markdown-section"
      content: "### <a name=register></a> register(name, reducer) → {[function](function)}\n\nRegisters a [reducer](reducer).\nA [reducer](reducer) has to be registered before it is used."
    - 
      type: "markdown-section"
      content: "<p class=\"sub-header\">Parameters:</p>\n<table><thead><tr><td>Name</td><td>Type</td><td>Description</td></tr></thead>\n<tr>\n                <td class=\"param-name\">name</td>\n                <td><p>string</p> </td>\n                <td><p>formal name for a reducer. If the given name already exists in store it is overridden by new      definition.</p> </td>\n            </tr>\n<tr>\n                <td class=\"param-name\">reducer</td>\n                <td><p>function</p> </td>\n                <td><p>definition of <a href=\"reducer\">reducer</a> function.</p> </td>\n            </tr></table>"
    - 
      type: "code-section"
      content: "// find the mean squared value of a given set\n const reducerStore = DataModel.Reducers();\n\n reducers.register('meanSquared', (arr) => {\n     const squaredVal = arr.map(item => item * item);\n     let sum = 0;\n     for (let i = 0, l = squaredVal.length; i < l; i++) {\n         sum += squaredVal[i++];\n     }\n\n     return sum;\n })\n\n // datamodel (dm) is already prepared with cars.json\n const dm1 = dm.groupBy(['origin'], {\n     accleration: 'meanSquared'\n });"
      preamble: ""
    - 
      type: "markdown-section"
      content: "<a name=function></a><p class=\"sub-header\">Returns:</p>\n\n <span style=\"font-family: 'Source Code Pro';margin-left: 2%;\">function:</span>function for unregistering the reducer."
