title: Redux Observable: How to return an action from a callback?
body: <p>I'm using the WebRTC library which has a very specific API. The <code>peerConnection.setRemoteDescription</code> method's 2nd argument is supposed to be a callback for when it finishes setting the remote description:</p>
  
  <p>This is one of my wrapper functions for my WebRTC class:</p>
  
  <pre><code>export function setRemoteSdp(peerConnection, sdp, callback) {
    if (!sdp) return;
    return peerConnection.setRemoteDescription(
      new RTCSessionDescription(sdp),
      callback, // &lt;-------------
    );
  }
  </code></pre>
  
  <p>And this is a sketch of what I want to do:</p>
  
  <pre><code>function receivedSdp(action$, store) {
    return action$.ofType(VideoStream.RECEIVED_SDP)
      .mergeMap(action =&gt; {
        const {peerConnection} = store.getState().videoStreams;
        const {sdp} = action.payload;
  
        return WebRTC.setRemoteSdp(peerConnection, sdp, () =&gt; {
          return myReducer.myAction(); // &lt;------ return action as the callback
        })
      })
  };
  </code></pre>
  
  <p>This doesn't work since I'm not returning an Observable. Is there a way to do this?</p>
  
  <p>P.S. this is the WebRTC API: <a href="https://github.com/oney/react-native-webrtc/blob/master/RTCPeerConnection.js#L176" rel="nofollow noreferrer">https://github.com/oney/react-native-webrtc/blob/master/RTCPeerConnection.js#L176</a></p>