title: Functional Programming in JavaScript - events
body: <p>I've been reading a fair amount about advantages of functional programming, and am trying to write some code which adheres to what might be considered functional programming. Immutability, Pure Functions, Local States, etc.</p>
  
  <p>The particular problem I have is as shown below. I'm not sure if there is some way to do what I want without breaking those rules. I guess I'm here to find that out.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let mouseDown = false;
  
  document.addEventListener('mousedown', () =&gt; mouseDown = true);
  document.addEventListener('mouseup', () =&gt; mouseDown = false);
  document.addEventListener('mousemove', e =&gt; {
    if (mouseDown) console.log({ x: e.movementX, y: e.movementY });
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>After spending 10+ years working with OOP, I'm finding it very hard to get a hand of FP. However, that's beside the point.</p>
  
  <p>So, my questions are:</p>
  
  <ol>
  <li>Is there a better way to solve this particular problem using functional programming?</li>
  <li>Should we be concerned about using functional programming <strong>everywhere</strong>?</li>
  </ol>