You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 20, 2018. It is now read-only.
<ahref="#rxhelpersdefaultcomparerx-y">#</a>[Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/basicheader.js"View in source")[Ⓣ][1]
20
+
21
+
The default equality comparer, used when a comparer is not supplied to a function. Uses an internal deep equality check.
<ahref="#rxhelpersdefaultsubcomparerx-y">#</a>[Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/basicheader.js"View in source")[Ⓣ][1]
49
+
50
+
The default comparer to determine whether one object is greater, less than or equal to another.
51
+
52
+
#### Arguments
53
+
1.`x`*(Any)*: The first value to compare
54
+
2.`y`*(Any)*: The second value to compare
55
+
56
+
#### Returns
57
+
*(Number)*: Returns `1` if `x` is greater than `y`, `-1` if `y` is greater than `x`, and `0` if the objects are equal.
<ahref="#rxhelpersdefaulterror">#</a>[Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/basicheader.js"View in source")[Ⓣ][1]
<ahref="#rxhelpersispromisep">#</a>[Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/basicheader.js"View in source")[Ⓣ][1]
148
+
149
+
A function which determines whether the object is a `Promise`.
150
+
151
+
#### Arguments
152
+
1.`p`*(Any)*: The object to determine whether it is a promise.
153
+
154
+
#### Returns
155
+
*(Boolean)*: `true` if the object is a `Promise` else `false`
156
+
157
+
#### Example
158
+
159
+
```js
160
+
var isPromise =Rx.helpers.isPromise;
161
+
162
+
var p =RSVP.Promise(function (res) { res(42); });
163
+
164
+
console.log(isPromise(p));
165
+
// => true
166
+
```
167
+
* * *
168
+
80
169
### <aid="rxhelpersnoop"></a>`Rx.helpers.noop()`
81
170
<ahref="#rxhelpersnoop">#</a>[Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/basicheader.js"View in source")[Ⓣ][1]
<ahref="#rxhelpersispromisep">#</a>[Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/basicheader.js"View in source")[Ⓣ][1]
<ahref="#rxhelperspluckproperty">#</a>[Ⓢ](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/basicheader.js"View in source")[Ⓣ][1]
97
186
98
-
A function which determines whether the object is a `Promise`.
187
+
Plucks a property from the object.
99
188
100
189
#### Arguments
101
-
1.`p`*(Any)*: The object to determine whether it is a promise.
190
+
1.`property`*(String)*: The property name to pluck from the object.
102
191
103
192
#### Returns
104
-
*(Boolean)*: `true` if the object is a `Promise`else `false`
Copy file name to clipboardExpand all lines: readme.md
+70-50Lines changed: 70 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,15 +45,15 @@ But the best news of all is that you already know how to program like this. Tak
45
45
var source =getStockData();
46
46
47
47
source
48
-
.filter(function (quote) {
49
-
returnquote.price>30;
50
-
})
51
-
.map(function (quote) {
52
-
returnquote.price;
53
-
})
54
-
.forEach(function (price) {
55
-
console.log('Prices higher than $30: $'+ price);
56
-
});
48
+
.filter(function (quote) {
49
+
returnquote.price>30;
50
+
})
51
+
.map(function (quote) {
52
+
returnquote.price;
53
+
})
54
+
.forEach(function (price) {
55
+
console.log('Prices higher than $30: $'+ price);
56
+
});
57
57
```
58
58
59
59
Now what if this data were to come as some sort of event, for example a stream, such as as a WebSocket, then we could pretty much write the same query to iterate our data, with very little change.
@@ -63,19 +63,19 @@ Now what if this data were to come as some sort of event, for example a stream,
63
63
var source =getAsyncStockData();
64
64
65
65
var subscription = source
66
-
.filter(function (quote) {
67
-
returnquote.price>30;
68
-
})
69
-
.map(function (quote) {
70
-
returnquote.price;
71
-
})
72
-
.subscribe(
73
-
function (price) {
74
-
console.log('Prices higher than $30: $'+ price);
75
-
},
76
-
function (err) {
77
-
console.log('Something went wrong: '+err.message);
78
-
});
66
+
.filter(function (quote) {
67
+
returnquote.price>30;
68
+
})
69
+
.map(function (quote) {
70
+
returnquote.price;
71
+
})
72
+
.subscribe(
73
+
function (price) {
74
+
console.log('Prices higher than $30: $'+ price);
75
+
},
76
+
function (err) {
77
+
console.log('Something went wrong: '+err.message);
78
+
});
79
79
80
80
/* When we're done */
81
81
subscription.dispose();
@@ -111,10 +111,10 @@ One question you may ask yourself, is why RxJS? What about Promises? Promises
111
111
To give you an idea about rich composition, we can create an autocompletion service which takes the user input from a text input and then query a service, making sure not to flood the service with calls for every key stroke, but instead allow to go at a more natural pace.
112
112
113
113
First, we'll reference the JavaScript files, including jQuery, although RxJS has no dependencies on jQuery...
Next, we'll get the user input from an input, listening to the keyup event by using the `Rx.Observable.fromEvent` method. This will either use the event binding from [jQuery](http://jquery.com), [Zepto](http://zeptojs.com/), [AngularJS](https://angularjs.org/) and [Ember.js](http://emberjs.com/) if available, and if not, falls back to the native event binding. This gives you consistent ways of thinking of events depending on your framework, so there are no surprises.
119
119
120
120
```js
@@ -214,6 +214,13 @@ You can find the documentation [here](https://github.com/Reactive-Extensions/RxJ
0 commit comments