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

Commit

Permalink
Updating to v2.2.28
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpodwysocki committed Jul 11, 2014
1 parent 800255c commit a741aa7
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 65 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rxjs",
"version": "2.2.27",
"version": "2.2.28",
"main": [
"dist/rx.all.js",
"dist/rx.all.min.js",
Expand Down
115 changes: 103 additions & 12 deletions doc/api/helpers/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,80 @@ Helper functions for the Reactive Extensions for JavaScript

## Documentation ##

- [`Rx.helpers.defaultComparer`](#rxhelpersdefaultcomparerx-y)
- [`Rx.helpers.defaultSubComparer`](#rxhelpersdefaultsubscomparerx-y)
- ['Rx.helpers.defaultError'](#rxhelpersdefaulterror)
- [`Rx.helpers.identity`](#rxhelpersidentityx)
- [`Rx.helpers.isPromise`](#rxhelpersispromisep)
- [`Rx.helpers.just`](#rxhelpersjustvalue)
- [`Rx.helpers.noop`](#rxhelpersnoop)
- [`Rx.helpers.pluck`](#rxhelperspluckproperty)

* * *

### <a id="rxhelpersdefaultcomparerx-y"></a>`Rx.helpers.defaultComparer(x, y)`
<a href="#rxhelpersdefaultcomparerx-y">#</a>[&#x24C8;](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/basicheader.js "View in source") [&#x24C9;][1]

The default equality comparer, used when a comparer is not supplied to a function. Uses an internal deep equality check.

#### Arguments
1. `x` *(Any)*: The first value to compare
2. `y` *(Any)*: The second value to compare

#### Returns
*(Boolean)*: `true` if equal; else `false`.

#### Example

```js
var comparer = Rx.helpers.defaultComparer;

// Should return true
var x = 42, y = 42
console.log(comparer(x, y));
// => true

// Should return false
var x = new Date(0), y = new Date();
console.log(comparer(x, y));
// => false
```
* * *

### <a id="rxhelpersdefaultsubcomparerx-y"></a>`Rx.helpers.defaultSubcomparer(x, y)`
<a href="#rxhelpersdefaultsubcomparerx-y">#</a>[&#x24C8;](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/basicheader.js "View in source") [&#x24C9;][1]

The default comparer to determine whether one object is greater, less than or equal to another.

#### Arguments
1. `x` *(Any)*: The first value to compare
2. `y` *(Any)*: The second value to compare

#### Returns
*(Number)*: Returns `1` if `x` is greater than `y`, `-1` if `y` is greater than `x`, and `0` if the objects are equal.

#### Example

```js
var comparer = Rx.helpers.defaultSubcomparer;

// Should return 0
var x = 42, y = 42
console.log(comparer(x, y));
// => 0

// Should return -1
var x = new Date(0), y = new Date();
console.log(comparer(x, y));
// => -1

// Should return 1
var x = 43, y = 42;
console.log(comparer(x, y));
// => 1
```
* * *

### <a id="rxhelpersdefaulterror"></a>`Rx.helpers.defaultError(err)`
<a href="#rxhelpersdefaulterror">#</a>[&#x24C8;](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/basicheader.js "View in source") [&#x24C9;][1]

Expand Down Expand Up @@ -77,6 +143,29 @@ Rx.Observable.timer(100)
```
* * *

### <a id="rxhelpersispromisep"></a>`Rx.helpers.isPromise(p)`
<a href="#rxhelpersispromisep">#</a>[&#x24C8;](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/basicheader.js "View in source") [&#x24C9;][1]

A function which determines whether the object is a `Promise`.

#### Arguments
1. `p` *(Any)*: The object to determine whether it is a promise.

#### Returns
*(Boolean)*: `true` if the object is a `Promise` else `false`

#### Example

```js
var isPromise = Rx.helpers.isPromise;

var p = RSVP.Promise(function (res) { res(42); });

console.log(isPromise(p));
// => true
```
* * *

### <a id="rxhelpersnoop"></a>`Rx.helpers.noop()`
<a href="#rxhelpersnoop">#</a>[&#x24C8;](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/basicheader.js "View in source") [&#x24C9;][1]

Expand All @@ -92,28 +181,30 @@ noop();
```
* * *

### <a id="rxhelpersispromisep"></a>`Rx.helpers.isPromise(p)`
<a href="#rxhelpersispromisep">#</a>[&#x24C8;](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/basicheader.js "View in source") [&#x24C9;][1]
### <a id="rxhelperspluckproperty"></a>`Rx.helpers.pluck(property)`
<a href="#rxhelperspluckproperty">#</a>[&#x24C8;](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/basicheader.js "View in source") [&#x24C9;][1]

A function which determines whether the object is a `Promise`.
Plucks a property from the object.

#### Arguments
1. `p` *(Any)*: The object to determine whether it is a promise.
1. `property` *(String)*: The property name to pluck from the object.

#### Returns
*(Boolean)*: `true` if the object is a `Promise` else `false`
*(Boolean)*: `true` if equal; else `false`.

#### Example

```js
var isPromise = Rx.helpers.isPromise;
var pluck = Rx.helpers.pluck;

var p = RSVP.Promise(function (res) { res(42); });
var source = Rx.Observable.interval(1000)
.timeInterval()
.map(pluck('value'))
.take(3);

var isPromise(p);
console.log(p);
// => true
source.subscribe(console.log.bind(console));
// => 0
// => 1
// => 2
```
* * *


4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "rx",
"title": "Reactive Extensions for JavaScript (RxJS)",
"description": "Library for composing asynchronous and event-based operations in JavaScript",
"version": "2.2.27",
"version": "2.2.28",
"homepage": "https://github.com/Reactive-Extensions/RxJS",
"author": {
"name": "Cloud Programmability Team",
Expand All @@ -20,7 +20,7 @@
],
"bugs": "https://github.com/Reactive-Extensions/RxJS/issues",
"jam": {
"main": "rx.js"
"main": "dist/rx.all.js"
},
"dependencies": {},
"devDependencies": {
Expand Down
120 changes: 70 additions & 50 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ But the best news of all is that you already know how to program like this. Tak
var source = getStockData();

source
.filter(function (quote) {
return quote.price > 30;
})
.map(function (quote) {
return quote.price;
})
.forEach(function (price) {
console.log('Prices higher than $30: $' + price);
});
.filter(function (quote) {
return quote.price > 30;
})
.map(function (quote) {
return quote.price;
})
.forEach(function (price) {
console.log('Prices higher than $30: $' + price);
});
```

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.
Expand All @@ -63,19 +63,19 @@ Now what if this data were to come as some sort of event, for example a stream,
var source = getAsyncStockData();

var subscription = source
.filter(function (quote) {
return quote.price > 30;
})
.map(function (quote) {
return quote.price;
})
.subscribe(
function (price) {
console.log('Prices higher than $30: $' + price);
},
function (err) {
console.log('Something went wrong: ' + err.message);
});
.filter(function (quote) {
return quote.price > 30;
})
.map(function (quote) {
return quote.price;
})
.subscribe(
function (price) {
console.log('Prices higher than $30: $' + price);
},
function (err) {
console.log('Something went wrong: ' + err.message);
});

/* When we're done */
subscription.dispose();
Expand Down Expand Up @@ -111,10 +111,10 @@ One question you may ask yourself, is why RxJS? What about Promises? Promises
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.

First, we'll reference the JavaScript files, including jQuery, although RxJS has no dependencies on jQuery...

<script src="http://code.jquery.com/jquery.js"></script>
<script src="rx.lite.js"></script>

```html
<script src="http://code.jquery.com/jquery.js"></script>
<script src="rx.lite.js"></script>
```
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.

```js
Expand Down Expand Up @@ -214,6 +214,13 @@ You can find the documentation [here](https://github.com/Reactive-Extensions/RxJ
- [RxJS Koans](https://github.com/mattpodwysocki/RxJSKoans)
- [Rx Workshop](http://rxworkshop.codeplex.com/)
- [The introduction to Reactive Programming you've been missing](https://gist.github.com/staltz/868e7e9bc2a7b8c1f754)
- [Reactive Programming and MVC](http://aaronstacy.com/writings/reactive-programming-and-mvc/)

- Examples
- [React RxJS Autocomplete](https://github.com/eliseumds/react-autocomplete)
- [React RxJS TODO MVC](https://github.com/fdecampredon/react-rxjs-todomvc)
- [Ninya.io - Angular + RxJS + rx.angular.js](https://github.com/ninya-io/ninya.io) - [Site](http://stackwho.herokuapp.com/)
- [Reactive Trader](https://github.com/AdaptiveConsulting/ReactiveTrader) - [Site](https://reactivetrader.azurewebsites.net/)

- Presentations
- Don't Cross the Streams - Cascadia.js 2012 [slides/demos](http://www.slideshare.net/mattpodwysocki/cascadiajs-dont-cross-the-streams) | [video](http://www.youtube.com/watch?v=FqBq4uoiG0M)
Expand All @@ -230,11 +237,13 @@ You can find the documentation [here](https://github.com/Reactive-Extensions/RxJ
- [Adding Even More Fun to Functional Programming With RXJS - Ryan Anklam](https://www.youtube.com/watch?v=8EExNfm0gt4)

- Reference Material
- [RxJS GitBook](http://xgrommx.github.io/rx-book/)
- [Intro to Rx](http://introtorx.com/)
- [101 Rx Samples Wiki](http://rxwiki.wikidot.com/101samples)
- [Rx Design Guidelines](http://go.microsoft.com/fwlink/?LinkID=205219)
- [Beginners Guide to Rx](http://msdn.microsoft.com/en-us/data/gg577611)


- Books
- [Intro to Rx](http://www.amazon.com/Introduction-to-Rx-ebook/dp/B008GM3YPM/)
- [Programming Reactive Extensions and LINQ](http://www.amazon.com/Programming-Reactive-Extensions-Jesse-Liberty/dp/1430237473/)
Expand All @@ -245,22 +254,29 @@ There are a number of ways to get started with RxJS. The files are available on

### Download the Source

git clone https://github.com/Reactive-Extensions/rxjs.git
cd ./rxjs
```bash
git clone https://github.com/Reactive-Extensions/rxjs.git
cd ./rxjs
```

### Installing with [NPM](https://npmjs.org/)

npm install rx
npm install -g rx
WARNING: 'npm install rxjs' will install an old, out of date, 3rd party version of Rx.
```bash`
npm install rx
npm install -g rx
```
### Using with Node.js and Ringo.js
var Rx = require('rx');
```js
var Rx = require('rx');
```

### Installing with [Bower](http://bower.io/)

bower install rxjs
```bash
bower install rxjs
```

### Installing with [Jam](http://jamjs.org/)

Expand All @@ -287,27 +303,31 @@ There are a number of ways to get started with RxJS. The files are available on

### In a Browser:

<!-- Just the core RxJS -->
<script src="rx.js"></script>
```html
<!-- Just the core RxJS -->
<script src="rx.js"></script>

<!-- Or all of RxJS minus testing -->
<script src="rx.complete.js"></script>
<!-- Or all of RxJS minus testing -->
<script src="rx.complete.js"></script>

<!-- Or keeping it lite -->
<script src="rx.lite.js"></script>
<!-- Or keeping it lite -->
<script src="rx.lite.js"></script>
```

### Along with a number of our extras for RxJS:

<script src="rx.aggregates.js"></script>
<script src="rx.async.js"></script>
<script src="rx.backpressure.js"></script>
<script src="rx.binding.js"></script>
<script src="rx.coincidencejs"></script>
<script src="rx.experimental.js"></script>
<script src="rx.joinpatterns.js"></script>
<script src="rx.time.js"></script>
<script src="rx.virtualtime.js"></script>
<script src="rx.testing.js"></script>
```html
<script src="rx.aggregates.js"></script>
<script src="rx.async.js"></script>
<script src="rx.backpressure.js"></script>
<script src="rx.binding.js"></script>
<script src="rx.coincidencejs"></script>
<script src="rx.experimental.js"></script>
<script src="rx.joinpatterns.js"></script>
<script src="rx.time.js"></script>
<script src="rx.virtualtime.js"></script>
<script src="rx.testing.js"></script>
```

### Using RxJS with an AMD loader such as Require.js

Expand Down Expand Up @@ -350,7 +370,7 @@ You can contribute by reviewing and sending feedback on code checkins, suggestin

Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
Microsoft Open Technologies would like to thank its contributors, a list
of whom are at http://rx.codeplex.com/wikipage?title=Contributors.
of whom are at https://github.com/Reactive-Extensions/RxJS/wiki/Contributors.

Licensed under the Apache License, Version 2.0 (the "License"); you
may not use this file except in compliance with the License. You may
Expand Down

0 comments on commit a741aa7

Please sign in to comment.