Reactive-Extensions/rx.angular.js — pull request #35 by chexxor (2014-07-09 07:28:20+00:00)
Title: Add 'digestObservables' and 'Observable.digest' utilities.

Just looking for your opinion on this addition to the rx-angular package. If you like it, we can add some tests and docs and such. These seem pretty useful to me, but this is only my second week learning RxJS, so I could be wrong.

These are transplanted from the [angular-bacon](https://github.com/lauripiispanen/angular-bacon) plugin. To see this style used in code, see the [example](https://github.com/lauripiispanen/angular-bacon/blob/master/examples/form-validation.js) they have, which demos a form validation use-case.

##### Observable.prototype.digest

The `Observable.prototype.digest` function helps reduce the code in my controller from

AppState.userStream.subscribe(function(newValue) {
$scope.$evalAsync(function(scope) {
scope.user = newValue;
});
});

to

AppState.userStream.
digest($scope, 'user');

##### $scope.digestObservables

The `$scope.digestObservables` function relies on that `Observable` extension, and allows us to reduce this

AppState.userStream.
digest($scope, 'user');

AppState.loginStatusStream.
digest($scope, 'loginStatus');

AppState.credentialsStatusStream.
digest($scope, 'credentialsStatus');

to

$scope.digestObservables({
'user': AppState.userStream,
'loginStatus': AppState.loginStatusStream,
'credentialsStatus': AppState.credentialsStatusStream
});