Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Commit 1b9523d

Browse files
Updating documentation
1 parent bffd253 commit 1b9523d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

readme.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ The goal here is to take the input from our textbox and throttle it in a way tha
4444
var throttledInput = $('#textInput')
4545
.keyupAsObservable()
4646

47-
Since we're only interested in the text, we'll use the [select]((http://msdn.microsoft.com/en-us/library/hh244311(v=VS.103).aspx)) method to take the event object and return the target's value.
47+
Since we're only interested in the text, we'll use the [select](http://msdn.microsoft.com/en-us/library/hh244311\(v=VS.103\).aspx) method to take the event object and return the target's value.
4848

4949
.select( function (ev) {
5050
return $(ev.target).val();
5151
})
5252

53-
We're also not interested in query terms less than two letters, so we'll trim that user input by using the [where]((http://msdn.microsoft.com/en-us/library/hh229267(v=VS.103).aspx)) method returning whether the string length is appropriate.
53+
We're also not interested in query terms less than two letters, so we'll trim that user input by using the [where](http://msdn.microsoft.com/en-us/library/hh229267\(v=VS.103\).aspx) method returning whether the string length is appropriate.
5454

5555
.where( function (text) {
5656
return text.length > 2;
5757
})
5858

59-
We also want to slow down the user input a little bit so that the external service won't be flooded with requests. To do that, we'll use the [throttle]((http://msdn.microsoft.com/en-us/library/hh229298(v=VS.103).aspx))method with a timeout of 500 milliseconds, which will ignore your fast typing and only return a value after you have paused for that time span.
59+
We also want to slow down the user input a little bit so that the external service won't be flooded with requests. To do that, we'll use the [throttle](http://msdn.microsoft.com/en-us/library/hh229298\(v=VS.103\).aspx) method with a timeout of 500 milliseconds, which will ignore your fast typing and only return a value after you have paused for that time span.
6060

6161
.throttle(500)
6262

@@ -77,7 +77,7 @@ Putting it all together, our throttledInput looks like the following:
7777
.throttle(500)
7878
.distinctUntilChanged();
7979

80-
Now that we have the throttled input from the textbox, we need to query our service, in this case, the Wikipedia API, for suggestions based upon our input. To do this, we'll create a function called searchWikipedia which calls the jQuery.ajaxAsObservable method which wraps the existing jQuery Ajax request in an RxJS [AsyncSubject]((http://msdn.microsoft.com/en-us/library/hh229363(v=VS.103).aspx)).
80+
Now that we have the throttled input from the textbox, we need to query our service, in this case, the Wikipedia API, for suggestions based upon our input. To do this, we'll create a function called searchWikipedia which calls the jQuery.ajaxAsObservable method which wraps the existing jQuery Ajax request in an RxJS [AsyncSubject](http://msdn.microsoft.com/en-us/library/hh229363\(v=VS.103\).aspx).
8181

8282
function searchWikipedia(term) {
8383
return $.ajaxAsObservable({
@@ -89,7 +89,7 @@ Now that we have the throttled input from the textbox, we need to query our serv
8989
});
9090
}
9191

92-
Now that the Wikipedia Search has been wrapped, we can tie together throttled input and our service call. In this case, we will call select on the throttledInput to then take the text from our textInput and then use it to query Wikipedia, filtering out empty records. Finally, to deal with concurrency issues, we'll need to ensure we're getting only the latest value. Issues can arise with asynchronous programming where an earlier value, if not cancelled properly, can be returned before the latest value is returned, thus causing bugs. To ensure that this doesn't happen, we have the [switchLatest]((http://msdn.microsoft.com/en-us/library/hh229197(v=VS.103).aspx)) method which returns only the latest value.
92+
Now that the Wikipedia Search has been wrapped, we can tie together throttled input and our service call. In this case, we will call select on the throttledInput to then take the text from our textInput and then use it to query Wikipedia, filtering out empty records. Finally, to deal with concurrency issues, we'll need to ensure we're getting only the latest value. Issues can arise with asynchronous programming where an earlier value, if not cancelled properly, can be returned before the latest value is returned, thus causing bugs. To ensure that this doesn't happen, we have the [switchLatest](http://msdn.microsoft.com/en-us/library/hh229197\(v=VS.103\).aspx) method which returns only the latest value.
9393

9494
var suggestions = throttledInput.select( function (text) {
9595
return searchWikipedia(text);
@@ -139,6 +139,7 @@ We've only scratched the surface of this library in this simple example.
139139
* [mouseenter](http://api.jquery.com/mouseenter/) - mouseenterAsObservable
140140
* [mouseleave](http://api.jquery.com/mouseleave/) - mouseleaveAsObservable
141141
* [mousemove](http://api.jquery.com/mousemove/) - mousemoveAsObservable
142+
* [mouseout](http://api.jquery.com/mouseout/) - mouseoutAsObservable
142143
* [mouseover](http://api.jquery.com/mouseover/) - mouseoverAsObservable
143144
* [mouseup](http://api.jquery.com/mouseup/) - mouseupAsObservable
144145
* [ready](http://api.jquery.com/ready/) - readyAsObservable
@@ -167,11 +168,11 @@ We've only scratched the surface of this library in this simple example.
167168
* [getScript](http://api.jquery.com/jQuery.getScript/) - getScriptAsObservable
168169
* [post](http://api.jquery.com/jQuery.post/) - postAsObservable
169170

170-
* Deferreds
171+
* [Deferred Object](http://api.jquery.com/category/deferred-object/)
171172
* Deferred.toObservable
172173
* Rx.Observable.toDeferred
173174

174-
* Callbacks
175+
* [Callbacks Object](http://api.jquery.com/category/callbacks-object/)
175176
* Callbacks.toObservable
176177

177178
## LICENSE

0 commit comments

Comments
 (0)