Code Monkey home page Code Monkey logo

rxjs's Introduction

Build Status GitHub version NPM version Downloads Bower NuGet Join the chat at https://gitter.im/Reactive-Extensions/RxJS

NOTE: The latest version of RxJS can be found here

The Need to go Reactive | About the Reactive Extensions | Batteries Included | Why RxJS? | Dive In! | Resources | Getting Started | What about my libraries? | Compatibility | Contributing | License

The Reactive Extensions for JavaScript (RxJS) 4.0...

...is a set of libraries to compose asynchronous and event-based programs using observable collections and Array#extras style composition in JavaScript

The project is actively developed by Microsoft, in collaboration with a community of open source developers.

The Need to go Reactive

Applications, especially on the web have changed over the years from being a simple static page, to DHTML with animations, to the Ajax revolution. Each time, we're adding more complexity, more data, and asynchronous behavior to our applications. How do we manage it all? How do we scale it? By moving towards "Reactive Architectures" which are event-driven, resilient and responsive. With the Reactive Extensions, you have all the tools you need to help build these systems.

About the Reactive Extensions

The Reactive Extensions for JavaScript (RxJS) is a set of libraries for composing asynchronous and event-based programs using observable sequences and fluent query operators that many of you already know by Array#extras in JavaScript. Using RxJS, developers represent asynchronous data streams with Observables, query asynchronous data streams using our many operators, and parameterize the concurrency in the asynchronous data streams using Schedulers. Simply put, RxJS = Observables + Operators + Schedulers.

Whether you are authoring a web-based application in JavaScript or a server-side application in Node.js, you have to deal with asynchronous and event-based programming. Although some patterns are emerging such as the Promise pattern, handling exceptions, cancellation, and synchronization is difficult and error-prone.

Using RxJS, you can represent multiple asynchronous data streams (that come from diverse sources, e.g., stock quote, tweets, computer events, web service requests, etc.), and subscribe to the event stream using the Observer object. The Observable notifies the subscribed Observer instance whenever an event occurs.

Because observable sequences are data streams, you can query them using standard query operators implemented by the Observable type. Thus you can filter, project, aggregate, compose and perform time-based operations on multiple events easily by using these operators. In addition, there are a number of other reactive stream specific operators that allow powerful queries to be written. Cancellation, exceptions, and synchronization are also handled gracefully by using the methods on the Observable object.

But the best news of all is that you already know how to program like this. Take for example the following JavaScript code, where we get some stock data and then manipulate and iterate the results.

/* Get stock data somehow */
const source = getAsyncStockData();

const subscription = source
  .filter(quote => quote.price > 30)
  .map(quote => quote.price)
  .forEach(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 a WebSocket? Then we could pretty much write the same query to iterate our data, with very little change.

/* Get stock data somehow */
const source = getAsyncStockData();

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

/* When we're done */
subscription.dispose();

The only difference is that we can handle the errors inline with our subscription. And when we're no longer interested in receiving the data as it comes streaming in, we call dispose on our subscription. Note the use of subscribe instead of forEach. We could also use forEach which is an alias for subscribe but we highly suggest you use subscribe.

Batteries Included

Sure, there are a lot of libraries to get started with RxJS. Confused on where to get started? Start out with the complete set of operators with rx.all.js, then you can reduce it to the number of operators that you really need, and perhaps stick with something as small as rx.lite.js. If you're an implementor of RxJS, then you can start out with rx.core.js.

This set of libraries include:

The complete library:

Main Libraries:

Lite Libraries:

Core Libraries:

Why RxJS?

One question you may ask yourself is why RxJS? What about Promises? Promises are good for solving asynchronous operations such as querying a service with an XMLHttpRequest, where the expected behavior is one value and then completion. Reactive Extensions for JavaScript unify both the world of Promises, callbacks as well as evented data such as DOM Input, Web Workers, and Web Sockets. Unifying these concepts enables rich composition.

To give you an idea about rich composition, we can create an autocompletion service which takes user input from a text input and then throttles queries to a service (to avoid flooding the service with calls for every key stroke).

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

<script src="https://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, Zepto, AngularJS, Backbone.js and Ember.js 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.

const $input = $('#input');
const $results = $('#results');

/* Only get the value from each key up */
var keyups = Rx.Observable.fromEvent($input, 'keyup')
  .pluck('target', 'value')
  .filter(text => text.length > 2 );

/* Now debounce the input for 500ms */
var debounced = keyups
  .debounce(500 /* ms */);

/* Now get only distinct values, so we eliminate the arrows and other control characters */
var distinct = debounced
  .distinctUntilChanged();

Now, let's query Wikipedia! In RxJS, we can instantly bind to any Promises A+ implementation through the Rx.Observable.fromPromise method. Or, directly return it and RxJS will wrap it for you.

let searchWikipedia = (term) => {
  return $.ajax({
    url: 'https://en.wikipedia.org/w/api.php',
    dataType: 'jsonp',
    data: {
      action: 'opensearch',
      format: 'json',
      search: term
    }
  }).promise();
}

Once that is created, we can tie together the distinct throttled input and query the service. In this case, we'll call flatMapLatest to get the value and ensure we're not introducing any out of order sequence calls.

const suggestions = distinct
  .flatMapLatest(searchWikipedia);

Finally, we call the subscribe method on our observable sequence to start pulling data.

suggestions.subscribe(
  data => {
    $results
      .empty()
      .append($.map(data[1], value =>  $('<li>').text(value)));
  },
  error => {
    $results
      .empty()
      .append($('<li>'))
        .text(`Error: ${error}`);
  });

And there you have it!

Dive In!

Please check out:

Resources

Getting Started

There are a number of ways to get started with RxJS. The files are available on cdnjs and jsDelivr.

Download the Source

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

Installing with NPM

```bash` $ npm install rx $ npm install -g rx


### Using with Node.js and Ringo.js

```js
var Rx = require('rx');

Installing with Bower

$ bower install rxjs

Installing with Jam

$ jam install rx

Installing All of RxJS via NuGet

$ Install-Package RxJS-All

Install individual packages via NuGet:

Install-Package RxJS-All
Install-Package RxJS-Lite
Install-Package RxJS-Main
Install-Package RxJS-Aggregates
Install-Package RxJS-Async
Install-Package RxJS-BackPressure
Install-Package RxJS-Binding
Install-Package RxJS-Coincidence
Install-Package RxJS-Experimental
Install-Package RxJS-JoinPatterns
Install-Package RxJS-Testing
Install-Package RxJS-Time

In a Browser:

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

<!-- Or all of RxJS minus testing -->
<script src="rx.all.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>

Using RxJS with an AMD loader such as Require.js

require({
  'paths': {
    'rx': 'path/to/rx-lite.js'
  }
},
['rx'], (Rx) => {
  const obs = Rx.Observable.of(42);
  obs.forEach(x => console.log(x));
});

What about my libraries?

The Reactive Extensions for JavaScript have no external dependencies on any library, so they'll work well with just about any library. We provide bridges and support for various libraries including:

Compatibility

RxJS has been thoroughly tested against all major browsers and supports IE6+, Chrome 4+, FireFox 1+, and Node.js v0.4+.

Contributing

There are lots of ways to contribute to the project, and we appreciate our contributors. If you wish to contribute, check out our style guide.

You can contribute by reviewing and sending feedback on code checkins, suggesting and trying out new features as they are implemented, submit bugs and help us verify fixes as they are checked in, as well as submit code fixes or code contributions of your own. Note that all code submissions will be rigorously reviewed and tested by the Rx Team, and only those that meet an extremely high bar for both quality and design/roadmap appropriateness will be merged into the source.

First-time contributors must sign a Contribution License Agreement. If your Pull Request has the label cla-required, this is an indication that you haven't yet signed such an agreement.

License

Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. Microsoft Open Technologies would like to thank its contributors, a list 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 obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

rxjs's People

Contributors

38elements avatar atticoos avatar bartdesmet avatar benlesh avatar bouzuya avatar chetharrison avatar chicoxyzzy avatar david-driscoll avatar gordey4doronin avatar igorbek avatar jacksky007 avatar jca02266 avatar jhusain avatar jmalonzo avatar l8d avatar mattpodwysocki avatar paddlefish avatar paulpdaniels avatar raineratspirit avatar rhendric avatar scouten-adobe avatar sirbarrence avatar staltz avatar tavisrudd avatar theghostbel avatar urmastalimaa avatar widdershin avatar xgrommx avatar yungsters avatar zalastax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rxjs's Issues

switchLatest() defeats distinctUntilChanged()

I'm trying to follow the patterns in the examples, that look something like

return anObservable.distinctUntilChanged()
    .select(function (d) { return $.postAsObservable(d); })
    .switchLatest();

However the switchLatest() creates new subscriptions on the observable, such that the distinctUntilChanged() is defeated (it's always a new stream), and duplicate requests are sent to the server. I can work around this with publish().

var reqs = anObservable.distinctUntilChanged()
      .select(function(d) { return $.postAsObservable(d); })
      .publish();
reqs.connect();
return reqs.switchLatest();

but it's awkward, and the examples suggest the simpler pattern should work.

Merge fails on an array with Observables

Whereas in the old RxJS version you were able to do the follwing:

Rx.Observable.Merge([Rx.Observable.Return(3), Rx.Observable.Return(5)]).Subscribe(function(x){ console.log(x); });
//prints
3
5

With the new version this throws an error:

Rx.Observable.merge([Rx.Observable.returnValue(3), Rx.Observable.returnValue(5)]).subscribe(function(x){ console.log(x); });
//throws TypeError: Object [object Object],[object Object] has no method 'scheduleRecursive'

looking at the minified source (sigh) it seems to be failing at this point:

var ga = j.fromArray = function(a, b) {
        b || (b = D);
        return i(function(c) {
            var d = 
            0;
            //BOOOOM b seems to be an array here
            return b.scheduleRecursive(function(b) {
Uncaught TypeError: Object [object Object],[object Object] has no method 'scheduleRecursive'
                if (d < a.length)
                    c.onNext(a[d++]), b();
                else
                    c.onCompleted()
            })
        })

Simplify the API

The API of RxJS looks a lot like a C# lib and in general a little verbose. So I want to suggest to talk about a simpler API design. Let me give some examples.

var source = Rx(target, 'mousemove');
Instead of
var source = Rx.Observable.fromEvent(target, 'mousemove');

var source = Rx($.getJSON('/products').promise());
Instead of
var source = Rx.Observable.fromPromise($.getJSON('/products').promise());

Add Events and Promises to Core

Given that ES6 is coming with Promises, and most libraries support them, should Promises be supported in the core such as:
https://gist.github.com/mattpodwysocki/6954807

We could have standard event support such as for Node.js and DOM as well:
https://gist.github.com/mattpodwysocki/6954620

Plus we could add a bridge support to have a fromEventPattern which would allow for any library to interact with standard events:
https://gist.github.com/mattpodwysocki/6954510

Which parts of these should be included?

How to extend Rx.Observable.prototype?

Hello,

How can i extend Rx.Observable.prototype in nodejs?

Let say i have the following project structure:

lib
|----rx
|----rx-fs
|    |
|    `----rx
|
`----rx-utils
     |
     `----rx

All changes made in rx-fs are not visible in rx-utils and in lib because they have their own copy of Rx;

I would like to write the code below in lib module:

rxfs
    .readFile("file.txt")    //rx-fs
    .concatBuffers()       //rx-utils
    .subscribe(function (buffer) { ... }, ...);

How can i extend Rx.Observable.prototype in nodejs?

Thanks

Bug in delayWithSelector

When invoking delayWithSelector with a subscription delay, an exception is thrown for the following reason:

subscription.setDisposable(subDelay.subscribe(function () {
  start();
}, observer.onError.bind(onError), function () { start(); }));

should be

subscription.setDisposable(subDelay.subscribe(function () {
  start();
}, observer.onError.bind(observer.onError), function () { start(); }));

otherwise, the bind throws an exception, and the whole thing goes kaput.

Make versions for compat and move rx.modern.js to rx.js

Since others such as jQuery and lodash are making the move to dropping older browsers from mainline support, it's about time RxJS does the same. Instead of shipping rx.modern.js, we will ship it as rx.js and maintain the existing rx.js as rx.compat.js.

Going forward, you can use an ES5 shim library to polyfill behavior such as Function#bind, and Array#extras which is all that RxJS relies upon.

What is RxJS?

Your web site starts:

"RxJS a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators."

...Hm, sounds interesting I'll read more...

But next I need to know what you mean by observable sequences and LINQ then an example of how RxJS does the magic of the first sentence.

So by the second sentence I'm wondering if I will learn anything; the next paragraph gives the answer: no :-(. The next paragraph and the example that follows seems to be some kind of detail or at least not about the key idea of RxJS.

HTH....

Roadmap for 2.3

Version 2.3:

  • Query Expressions for both RxJS and IxJS
  • Revisit Backpressure?
  • Investigate ES6 implications

Incomplete Array#indexOf polyfill

Hi,

The implemented indexOf Array polyfill yields an incorrect result when called with undefined as the second argument (fromIndex).

The polyfill should default to 0 when a non-Integer fromIndex value is encountered.

This affects IE version 8 and below.

Test case:
[1,2,3,4].indexOf(3, undefined);

Expected result: 2
Actual result: -1

Thanks,

  • Ewan

fromEvent() for node iffy

Before a recent refactor the fromEvent() method for node would generate an observable that would emit the arguments object as received by the internal handler. After a recent refactor the fromEvent() method for node only emits the first argument as received by the internal handler.

As a result, when attempting to generate an Observable from an http request event the Observable only emits the request parameter and leaves out the response parameter. The response object should not be dropped.

Getting Started

I'm just trying to get started. I downloaded the project and tried one of the examples, autocomplete.html. It has errors "Error Rx is undefined". I open the html file and find references to "../lib/rx.js" but there is no lib folder in the project. I change this to "../../rx.js" but continue to get errors ("object does not support this property "fromevent"). I go to the root folder and try running build_core.bat but it complains that "grunt" is missing. I install node.js, then install grunt, build_core runs w/o errors, great! But still have no idea how to run the examples.

Update or at least remove generated content

The current landing page has all the default content from the Github Pages generator. Rather than leaving the default, remove it or update it with something even a bit more informative, such as links to the Rx MSDN site or Channel 9 content.

Github or CodePlex the master?

I just noticed that there are more current commits to the Github repo than to the CodePlex repo. Which one is the center of activity (please say Github :) ?

Possible bug with merge

I tried to port over Dave Sextons' method for forkJoin to bring it back for the latest RxJS release. As Matt pointed out, it will come back with rx-experimential.js but in the mean time one could use this.

However, when I translate it one by one it doesnt work:

Rx.Observable.forkJoin = function (sources) {
        return Rx.Observable.fromArray(sources)
                .select(function(o, i) {
                     return o.takeLast(1).select(function(value) { return { i: i, value: value }; });
                })
                .merge(null)
                .aggregate({ array: [], count: 0 }, function(results, result) {
                    results.array[result.i] = result.value;
                    return {
                        array: results.array,
                        count: results.count + 1
                    };
                })
                .where(function(results) { return results.count === sources.length; })
                .select(function(results) { return results.array; });
    };

instead I have to do it like this:

Rx.Observable.forkJoin = function (sources) {
        return Rx.Observable.fromArray(sources)
                .selectMany(function(o, i) {
                     return o.takeLast(1).select(function(value) { return { i: i, value: value }; });
                })
                .aggregate({ array: [], count: 0 }, function(results, result) {
                    results.array[result.i] = result.value;
                    return {
                        array: results.array,
                        count: results.count + 1
                    };
                })
                .where(function(results) { return results.count === sources.length; })
                .select(function(results) { return results.array; });
    };

Rx.Observable.combineLatest

Before I get started, let me say that I am willing (wanting) to make the following changes, if such an idea is deemed worthy of approval.

I've been working extensively with RxJS lately, and found that Rx.Observable.prototype.combineLatest does not have a non-prototype counterpart, and does not accept an Array of sources as it's first parameter. For instance, the following exists:

1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });

Which is technically incorrect, and should be:

1 - obs = obs1.combineLatest(obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });

But I would propose expanding this to include:

// Rx.Observable.prototype
1 - obs = obs1.combineLatest(obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
2 - obs = obs1.combineLatest([obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
// Rx.Observable
1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });

Currently, the prototype method is the only method that exists, but I would suggest this method be refactored to move its implementation to a function not on the prototype. The prototype's functions would then invoke the non-prototype functions, in an effort to keep things dry.

Is this a good idea, and is there any hope of it reaching the RxJS code base?

selectManyLatest Issue

Hi there,
I think there is an issue with either doc or this function, when I try to run the example in docs, it says cannot subscribe to object1.

--Troki

Bad filenames in RxJs-Main nuget package

These are the files in the packages (likes like we got x instead of rx for some of the files):

$ ls -l packages/RxJS-Main.2.2.0/content/Scripts
total 215
-rw-r--r--    1 Brandon. Administ   181727 Nov 17 14:19 rx.compat.js
-rw-r--r--    1 Brandon. Administ   177601 Nov 17 14:19 rx.js
-rw-r--r--    1 Brandon. Administ    40293 Nov 17 14:19 x.compat.min.js
-rw-r--r--    1 Brandon. Administ    38574 Nov 17 14:19 x.min.js

API docs?

The docs look mostly incomplete. I understand this is based on Rx for .NET, so perhaps the Rx docs would do, but I can't find Rx docs, either, apart from some very high-level videos on msdn. Where's the API reference?

Wrong `this`

This line:

https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable.coincidence.js#L260

observableWindowWithOpenings(this, bufferOpeningsOrClosingSelector, bufferClosingSelector)

Should actually be:

observableWindowWithOpenings.call(this, bufferOpeningsOrClosingSelector, bufferClosingSelector)

Just like this line does: https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable.coincidence.js#L278

Notice the call call. Otherwise, the this from here will be the global object:

https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable.coincidence.js#L282

Rx.Observable.prototype.publishLast is missing

Hello,

Rx.Observable.prototype.publishLast is missing in NodeJS because two different Rx objects are used.

version": "2.1.2"

This code snippet can reproduce the issue:
$ node
> var Rx = require('rx');
> Rx.Observable.prototype.publishLast

in rx.node.js:1 it is ./rx.modern:

var Rx = require('./rx.modern');

in rx.binding.js:18 it is ./rx:

module.exports = factory(root, module.exports, require('./rx'));

Scan with multiple subscribers results in weird behaviour

I have an ClojureScript app which uses Observable.scan to implement global state change on signal changes. That worked out pretty well until I started having multiple subscribers for global state change.

Namely, the state in one of subscribers is different from the state in the other ones. Trying to understand how is that possible I've noticed that my aggregating function is called twice per every state change. It seems that somehow the signal paths diverged and it all got mixed up.

The case of aggregation function being called twice was easily reproduced:

http://jsfiddle.net/4AayC/2/ (yes it's a weird example)

I'm not really sure how to reproduce difference in states easily, my few attempts were failed.

I suspect that there may be a problem in how I use the scan method (documentation is particularly helpful on this one ;-) ) or on my approach to the overall system design, however I have no clue where exactly my error is.

I'm not relying on any global variables in my own code, it all is pure. I can try to provide some more info somehow (maybe even show the code, if ClojureScript is okay), if it's needed. Maybe it's a ClojureScript bug, some pure operation does not happen to actually be pure; however in the JavaScript world accidentally impure operations are a norm, so it's hard to imagine RxJS being better in this case with JS than CS.

Almost real example of application with RxJS as a spine

There is very good trend - every js framework should prove it's power by submitting yet-another TODO app - http://todomvc.com

At the moment RxJS is not mentioned there. Also all examples I've met are a bit "artificial", they don't reveal the real power.

I was thinking about app that will use _.underscore (or loadash - mostly for templating and FP aspect) and require.js (for making tiny files/modules).

Should we start from creating subdir ./RxJS/TODO app?

rxjs-modern is missing from nuget.org

rxjs-coincidence has a dependency on rxjs-modern which is not published to nuget.org

Therefore updating to latest version fails.

Trying to install rxjs-all also fails for the same reason.

no more vsdoc files?

RxJs 2.0 had vsdoc files. I see that RxJs 2.2 doesn't seem to have them anymore. Have they been abandoned?

Any advice on how to get VS2012 to show meaningful intellisense when typing . for an Rx observable?

Consider including method for binding DOM events in core rx.js library?

Hi,
In the core rx.js library I don't think there is currently a way to bind to a dom event such as a button click e.g. something like:

function CreateObservable(element, eventType) {

return Rx.Observable.create(function(observer) {

    function eventHandler (eventObj) {
        observer.onNext(eventObj);              
    }

    //keep simple for example & ignore addEventListener/attachEvent browser differences
    element.addEventListener(eventType, eventHandler);

    return function() {
        element.removeEventListener(eventType, eventHandler);
    };
});

};

I am of two minds about this decision and I can see why you have separated this functionality out of the core library and that rx.js could be used for other non web page scenarios such as . node.

However it's a pain for new users getting started to have to create their own observable creation method or reference another script like rx.jquery.js to bind to simple events - either way I think the documentation can be improved on this aspect?

rx-dom cannot be installed with bower

bower info rx reports the package as non-existent, but bower info rx-dom reports the rx package as a dependency. The net effect is that rx-dom cannot be installed.

The only existent package right now is rxjs. Not sure where the problem lies, but personally I prefer rxjs being renamed to rx. Sounds better IMHO, and that's why I added this issue here instead of using the rx-dom repo.

Split each operator into its own file for custom builds

In order to make custom builds easier, should we split each operator into its own file and then maintain a dependency chart so that we know what each operator depends on? This could dramatically alter the size of RxJS and give you only the operators you want/need. This falls much in line with what lo-dash has been doing very recently.

Subscribe and timeout

How can I get a each value with timeout in subscribe?

For example now I try it, but it work for all collection in unlike for each value of collection.

            Rx.Observable.fromArray([1,2,3,4,5,6,7]).delay(2000).subscribe(
                    function(v) {
                        console.log(v);
                    },
                    function(err) {

                    },
                    function() {
                        console.log('All done');
                    }); 

Rework docs

  1. No need in # link under the titles because when you hover the title it shows generated link for you
  2. Remove or make auto link for โ“ˆ link because all of the links in docs pointing on wrong lines numbers

Maybe remove both of that links and put Location file name on that line? If you agree, I can do that.

Multiple observable onNext args.

Right now the onNext function seems to only pass one element into the observable sequence. Can/Should we be able to create sequences which provide multiple arguments upon subscription?

Add jQuery/Zepto shortcuts for event binding

Instead of insisting upon using Rx.Observable.fromEvent, should we shim for jQuery and Zepto to something like this?

var proto;
if ('Zepto' in window && Zepto.fn) {
    proto = Zepto.fn;
} else if ('jQuery' in window && jQuery.fn) {
    proto = jQuery.fn;
} else if ('angular' in window) {
    proto = angular.element.prototype; 
}
if (proto) {
    /** 
     * Takes the current selector and converts it into an observable sequence with the given event name.
     * @param {String} eventName The event name to bind to the observable sequence.
     * @returns {Observable} An observable sequence which wraps the existing event stream based upon selector
     */
    proto.asObservable = function (eventName) {
       return Rx.Observable.fromEvent(this, eventName);
    };
}

var $results = $('#results');

var subscription = $(document).asObservable('mousemove')
    .subscribe(function (e) {
        $results.text(e.clientX + ',' + e.clientY);
    });

A JSFiddle can be found here which should easily work if you switch between jQuery and Zepto.

Question. Should this be added to the core?

Define rx.lite.js

Until we have custom builds under hand, would it make sense to create a smaller version of RxJS called RxLite which has a few operators. Which operators might fit?

Thoughts include the following:

Creation Operators

  • create
  • createWithDisposable
  • empty
  • fromArray
  • fromCallback
  • fromEvent
  • fromEventPattern
  • fromNodeCallback
  • fromPromise
  • interval
  • merge
  • never
  • repeat
  • return
  • timer

Combinators

  • do
  • map/select
  • filter/where
  • flatMap/selectMany
  • flatMapLatest/selectSwitch
  • combineLatest
  • zip
  • distinctUntilChanged
  • concat
  • concatObservable
  • merge
  • mergeObservable
  • multicast
  • publish
  • publishLatest
  • publishValue
  • repeat
  • replay
  • skip
  • skipUntil
  • skipWhile
  • take
  • takeUntil
  • takeWhile
  • throttle
  • timestamp
  • timeinterval
  • toArray

Any that I'm missing that are high priority?

npm installation

The documentation at https://github.com/Reactive-Extensions/RxJS says

npm install rxjs

but that apparently gets an ancient fork, namely

https://npmjs.org/package/rxjs

I think we should be doing

npm install rx

instead, getting

https://npmjs.org/package/rx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.