title: lodash throttle redux dispatch Uncaught TypeError: Expected a function
body: <p>TL;DR I am running into strangeness with creating a throttled function where I need to pass parameters to this method manually while creating the throttled function. I can do this by changing my original function, but I don't want to do this for all my old legacy functions/action creators.</p>
  
  <p><strong>The function passed to throttle:</strong> </p>
  
  <p><strong><em>Note:</strong> these are redux action creators.</em></p>
  
  <pre><code>const changeValue = (value: string, otherValue?: boolean) =&gt; {
      return {
          type: "SOME_TYPE",
          payload: {
              value: value,
              otherValue: otherValue || false
          }
      };
  };
  </code></pre>
  
  <p><strong>The creation of the throttled function:</strong> </p>
  
  <pre><code>const throttledMethod = (value: number, otherValue:boolean ) =&gt; {
      throttle(changeValue(Number(value),otherValue), 175, { "trailing": false });
  };
  </code></pre>
  
  <p>This normally expects a function to be passed and not the invocation,
  but then how can I pass parameters unless I am invoking? I don't want to curry in this situation.</p>
  
  <p>The error produced:</p>
  
  <pre><code>node_modules\lodash\throttle.js:56 Uncaught TypeError: Expected a function
      at throttle (node_modules\lodash\throttle.js:56)
  </code></pre>
  
  <p>When break pointed at line 56 in lodash and inspected we see that the value of the object returned from valueChanged:</p>
  
  <pre><code>{
      type: "SOME_TYPE",
      payload: {
      value: value,
      otherValue: otherValue || false
  }
  </code></pre>
  
  <p>That is all fair enough.</p>
  
  <p>The strangeness is that we get this to work by doing some relatively dirty manual work in the Redux action creator. I call this dirty because I don't want to change all of my old legacy action creators for this new thing I am doing.</p>
  
  <p>When I manually wrap my action creator like so with the Redux.js dispatch method everything starts working as expected.:</p>
  
  <pre><code>const changeValue = (value: string, otherValue?: boolean) =&gt; {
      return function (dispatch) {
          dispatch({
              type: "SOME_TYPE",
              payload: {
                  value: value,
                  otherValue: otherValue || false
              }
          });
      };
  };
  </code></pre>
  
  <p>So in the end this isn't really so much of an issue with Lodash, but still maybe we could address how to properly pass parameters to a method that needs to be passed to throttled without changing my all of my original methods or currying. Currying confuses a lot of people and in some situations I do somewhat want to pander to the less literate. </p>
  
  <p>Perhaps we can create a wrapper that handles manually wrapping dispatch when passing to lodash throttle or other methods. I think something like that would be ideal, but can't imagine what this wrapper would look like.</p>
  
  <p>Perhaps this is something I might ask the authors about, but first I wanted to attempt "userland".</p>