RxJS: Setting default value for observable from another observable
<p>I'm trying to create observable stream which takes user id from cookie and, if not found in cookie, fetches it from API. How can I do it in RxJS?</p>

<pre><code>var userIdRequest = Rx.Observable.bindCallback(generateIdAsync);
var cookieUserIdStream = Rx.Observable.of(getCookieValue("user_id"))
    .filter(x =&gt; x !== null);

var userIdStream = cookieUserIdStream.__ifEmptyThen__(userIdRequest()); // &lt;&lt;&lt; ???

// Emulating async request for user id
// Will be a JSONp call in real app
function generateIdAsync(cb) {
    setTimeout(() =&gt; {
        cb(`id_${new Date().getTime()}`);
    }, 300);
}

function getCookieValue(name) {
    var regexp = new RegExp(`${name}=([^;]*)`);
    var match = document.cookie.match(regexp);

    return match &amp;&amp; match[1];
}
</code></pre>

<p>There's a <code>defaultIfEmpty</code> method which works with simple values only, not with observables. In Bacon.js there's <code>or</code> method for streams, which works perfectly fine, but I don't see anything similar in RxJS. Do I miss something or do I need to implement a custom observer?</p>