Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove forEach and add "subscribe" overload #97

Merged
merged 5 commits into from
Jun 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 7 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,6 @@ Upon cancelation, the Observable's cleanup function will be executed.
subscription.unsubscribe();
```

Alternatively, we can subscribe to an Observable with the **forEach** method, which accepts
a single callback and returns a Promise.

```js
commandKeys(inputElement).forEach(val => {
console.log("Received key command: " + val);
});
```

```js
Observable.of(1, 2, 3, 4, 5)
.map(n => n * n)
.filter(n => n > 10)
.forEach(n => console.log(n))
.then(() => console.log("All done!"));
```

### Motivation ###

The Observable type represents one of the fundamental protocols for processing asynchronous
Expand Down Expand Up @@ -120,11 +103,13 @@ interface Observable {

constructor(subscriber : SubscriberFunction);

// Subscribes to the sequence
// Subscribes to the sequence with an observer
subscribe(observer : Observer) : Subscription;

// Subscribes to the sequence with a callback, returning a promise
forEach(onNext : any => any) : Promise;
// Subscribes to the sequence with callbacks
subscribe(onNext : Function,
onError? : Function,
onComplete? : Function) : Subscription;

// Returns itself
[Symbol.observable]() : Observable;
Expand All @@ -143,7 +128,7 @@ interface Subscription {
unsubscribe() : void;

// A boolean value indicating whether the subscription is closed
get closed() : Boolean
get closed() : Boolean;
}

function SubscriberFunction(observer: SubscriptionObserver) : (void => void)|Subscription;
Expand Down Expand Up @@ -265,6 +250,6 @@ interface SubscriptionObserver {
complete(completeValue);

// A boolean value indicating whether the subscription is closed
get closed() : Boolean
get closed() : Boolean;
}
```
Loading