title: How to use a generator function as a callback inside of a event listener
body: <p>I have a generator function that handles authentication and send a action to the redux store. 
  That function needs to be executed on a event. </p>
  
  <p>How can i use that as a callback inside of event listener?</p>
  
  <p>That's the function:</p>
  
  <pre><code>export function* authentication({ data }) {
    // Data structure {
    //   action: 'authentication',
    //   id: '7293847829109932,
    //   displayName: 'User Name',
    //   avatar: 'https://steamcommunity.com/images/user.png',
    //   access: 'access_token_string',
    //   refresh: 'refresh_token_string',
    // }
  
    // Will dispatch the success action if the data is correct
  
    if (data.action === 'error') {
      return yield put(signInFailure(data.message));
    }
    if (data.action === 'authentication') {
      localStorage.setItem('dualbits:access', data.access);
      localStorage.setItem('dualbits:refresh', data.refresh);
    }
  
    return yield put(signInSuccess(data));
  }
  </code></pre>
  
  <p>Event listener:</p>
  
  <pre><code> window.addEventListener('message', authentication, false);
  </code></pre>