title: How to pass function to the callback inside redux-saga using eventChannel
body: <p>I have redux-saga which makes a lot of stuff with the current session etc.
   Inside of one of my generator functions inside this saga I have a place which looks like this:</p>
  
  <pre><code>setSessionFailureHandler(() =&gt; {
    yield openMFAModal(account);
  });
  </code></pre>
  
  <p><code>setSessionFailureHandler</code> is the 3-rd party SDK inside which I need to pass a callback.
  <code>openMFAModal</code> is the redux action which opening the modal window.
  I'm using callback function from 3-d party SDK which should handle session failure and open modal window.
  Of course, I can't use yield inside the callback, that's why I'm trying to use eventChannel feature, I created a new function for the channel it looks like this:</p>
  
  <pre><code>function setSessionFailureChannel(data) {
    return eventChannel((emitter) =&gt; {
      setSessionFailureHandler(() =&gt; {
        const { function, account } = data;
        return emitter(function(account));
      });
    });
  }
  </code></pre>
  
  <p>Inside another generator, I'm trying to call this function with the callback but honestly for me not clear how to do this, all samples what I saw regarding eventChannel focused on the idea to pass some data through callBack to your saga, but what I need is to pass somehow my action to the callback which will call it after handle session failure.</p>
  
  <p>I'm trying to pass my action and argument for this action from my generator to this function like this:</p>
  
  <pre><code>const setSessionFailure = yield call(setSessionFailureChannel, { func: openMFAModal, account });
  while (true) {
     yield call(setSessionFailure);
  }
  </code></pre>
  
  <p>I know that it's the wrong approach, maybe someone did the same trick somehow and can explain how to do this correct?</p>