Note that there are some explanatory texts on larger screens.

plurals
  1. POIs anybody using rx.jquery?
    primarykey
    data
    text
    <p>Trying to get my feet wet with RxJS, specifically with rx.jquery. I found a little tutorial <a href="https://npmjs.org/package/rx-jquery" rel="nofollow">here</a> and tried to set it up as follows. It's supposed to take what you type and offer suggestions, pulled from Wikipedia. The call to Wikipedia is successful (I see in Chrome's Network debugging window), but the app gives me an error:</p> <blockquote> <p>Uncaught TypeError: Object #&lt;Object> has no method 'subscribe'</p> </blockquote> <p>I've tried several versions of jQuery (1.8.3, 1.10.2, 2.0.3), and that makes no difference. Bootstrap doesn't seem to be an issue, either. I see almost no mention of rx.jquery here (and there's no tag for it), so I don't know whether it's maybe not ready for prime-time or what. I have pulled the most recent rx.* libs, as older ones were giving me different errors.</p> <p>Of course, I can't rule out that I've just bungled something. But it's not jumping out at me.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;Reactive Elements&lt;/title&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt; &lt;meta name="apple-mobile-web-app-capable" content="yes" /&gt; &lt;link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" /&gt; &lt;script src="/lib/jquery-1.8.3.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="container"&gt; &lt;div class="page-header"&gt; &lt;h1&gt;Reactive Extensions &lt;small&gt;in JavaScript&lt;/small&gt;&lt;/h1&gt; &lt;/div&gt; &lt;input id="textInput" type="text" class="form-control"/&gt; &lt;ul id="results"&gt;&lt;/ul&gt; &lt;/div&gt; &lt;script src="/lib/rx.min.js"&gt;&lt;/script&gt; &lt;script src="/lib/rx.binding.min.js"&gt;&lt;/script&gt; &lt;script src="/lib/rx.time.min.js"&gt;&lt;/script&gt; &lt;script src="/lib/rx.jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(function () { var throttledInput = $('#textInput'). keyupAsObservable(). map(function (ev) { return $(ev.target).val(); }). filter(function (text) { return text.length &gt; 2; }). throttle(500). distinctUntilChanged(); function searchWikipedia(term) { return $.ajaxAsObservable({ url: 'http://en.wikipedia.org/w/api.php', data: { action: 'opensearch', search: term, format: 'json' }, dataType: 'jsonp' }); } var suggestions = throttledInput.flatMapLatest(function (text) { console.debug('Searching wiki', text); return searchWikipedia(text); }); var selector = $('#results'); suggestions.subscribe( function (data) { console.debug('Data!', data); selector.empty(); $.each(data[1], function (_, text) { $('&lt;li&gt;' + text + '&lt;/li&gt;').appendTo(selector); }); }, function (e) { console.debug("ERROR!", e); selector.empty(); $('&lt;li&gt;Error: ' + e + '&lt;/li&gt;').appendTo('#results'); } ); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload