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

Refactor to use bare RxJS implementations. #5288

Closed
wants to merge 4 commits into from

Conversation

robwormald
Copy link
Contributor

change RxJS implementation to use bare Observable and Subject with no included operators.

@robwormald robwormald force-pushed the refactor/observable branch 4 times, most recently from c9e8ca4 to b4a430d Compare November 14, 2015 08:55
@robwormald robwormald added the action: review The PR is still awaiting reviews from at least one requested reviewer label Nov 16, 2015
http.get('./people.json')
.map((res: Response) => res.json())
.subscribe((people: Array<Object>) => this.people = people);
http.get('./people.json').subscribe(res => { this.people = res.json(); });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this need to be changed as part of this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I changed that when I did the first commit, I'll add it back.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needs to be fixed.

@jeffbcross
Copy link
Contributor

Any reason why we can't just re-export Observable and add to the prototype? The only failure I see is the public API increasing because of all the static method stubs on Observable.

import {Observable} from '@reactivex/rxjs/dist/cjs/Observable';
export {Observable} from '@reactivex/rxjs/dist/cjs/Observable';

Observable.prototype.map = map;
Observable.prototype.filter = filter;

@jeffbcross
Copy link
Contributor

Also, @vsavkin made the valid point that we should include flatMap since it accepts observables, and is a good basis to chain operators. To not have flatMap would be crippling, and I should have added it in the original issue :(.

I'm going to chat with @IgorMinar about this PR, because he said he has some thoughts.

@robwormald robwormald added this to the beta-00 milestone Nov 16, 2015
@jeffbcross
Copy link
Contributor

@robwormald LGTM once you remove the last commit and finish the cleanup comments.

You could also wait until ReactiveX/rxjs#751 and ReactiveX/rxjs#750 land if you'd like.

@jeffbcross jeffbcross added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Nov 20, 2015
@jeffbcross jeffbcross assigned robwormald and unassigned jeffbcross Nov 20, 2015
@@ -3,9 +3,18 @@ import {global, isPresent} from 'angular2/src/facade/lang';
// without depending on rxjs.
import {PromiseWrapper, Promise, PromiseCompleter} from 'angular2/src/facade/promise';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove this unused import in a separate commit? I'd do it, but then I'd create a conflict for you

@IgorMinar
Copy link
Contributor

the rest looks good

@robwormald
Copy link
Contributor Author

ObservableWrapper.fromPromise / .toPromise are gonna fail now. Thoughts?

@IgorMinar
Copy link
Contributor

let's go with barebones first and then create PRs that add these things and
measure payload diff. Then decide.

On Sat, Nov 21, 2015 at 2:50 AM Rob Wormald notifications@github.com
wrote:

ObservableWrapper.fromPromise / .toPromise are gonna fail now. Thoughts?


Reply to this email directly or view it on GitHub
#5288 (comment).

@IgorMinar
Copy link
Contributor

barebones = what's in this PR now

On Sat, Nov 21, 2015 at 2:51 AM Igor Minar igor@angularjs.org wrote:

let's go with barebones first and then create PRs that add these things
and measure payload diff. Then decide.

On Sat, Nov 21, 2015 at 2:50 AM Rob Wormald notifications@github.com
wrote:

ObservableWrapper.fromPromise / .toPromise are gonna fail now. Thoughts?


Reply to this email directly or view it on GitHub
#5288 (comment).

@bradlygreen
Copy link
Contributor

@robwormald CI is failing...can you take a look?

move to new RxJS distribution.

BREAKING CHANGE:

RxJS imports now are via `rxjs` instead of `@reactivex/rxjs`
Individual operators can be imported `import 'rxjs/operators/map'`
@robwormald
Copy link
Contributor Author

alllllright, big changes. new version of rxjs in, minimal API surface

  • toPromise() / fromPromise() cc @vsavkin
  • take() (only in mock_backend)

@jeffbcross @IgorMinar plz discuss

@robwormald robwormald added action: review The PR is still awaiting reviews from at least one requested reviewer and removed pr_state: LGTM labels Dec 1, 2015
@robwormald robwormald assigned IgorMinar and unassigned alxhub Dec 1, 2015
@robwormald
Copy link
Contributor Author

will need to add following operators:

  • flatMap
  • map
  • from (spec)
  • of (spec)

@@ -13268,33 +13268,6 @@
}
}
},
"source-map-loader": {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the source-map-loader removed? It looks like something went wrong with the shrinkwrap process (npm install not executed?)

@pkozlowski-opensource
Copy link
Member

IMO shrinkwrap is broken in this PR. It needs to be corrected as it might break source maps for bundles.

} else {
return source;
}
var n = source.indexOf('System.register("rxjs/Subject"');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't omit the license. What is the underlying problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't ship in the new repo. I can grab it from the old I guess.

@jeffbcross
Copy link
Contributor

TODOs:

  • Add flatMap, map, from, of, filter, reduce operators
  • Measure difference in bundle size from bare Observable and Observable + ^^^ operators
  • Include rxjs in the benchpress bundle (it is required, and the previous exclude pattern doesn't seem to have actually been working)
  • Fix shrinkwrap to not remove sourcemap
  • Remove PromiseWrapper unused import in a separate commit
  • Restore E2E test to its former Rx-ified glory
  • Find a way to include the RxJS license

Regarding take in mock_backend, as long as we only import it in a testing barrel, no need to be concerned with added bytes.

I'll take care of all of the todos except the last one for now. @robwormald do you want to try to correct the license issue upstream and convince @Blesh to cut another RxJS release?

@mprobst
Copy link
Contributor

mprobst commented Dec 1, 2015

@jeffbcross I filed an issue for the newline-at-EOF, I don't think that's supported yet.

@jeffbcross
Copy link
Contributor

Thanks @mprobst!

@benlesh
Copy link
Contributor

benlesh commented Dec 1, 2015

Find a way to include the RxJS license

Is this to say that the new packages are missing the LICENSE file?... that's not good. lol

I'll take care of all of the todos except the last one for now. @robwormald do you want to try to correct the license issue upstream and convince @Blesh to cut another RxJS release?

The beta release is coming this week (hopefully in a couple of days). Does it need to be before that?

@robwormald
Copy link
Contributor Author

I'll fix the Rx stuff over there first, and in the interim can just grab
the license from the @ReactiveX package.
On Tue, Dec 1, 2015 at 12:03 PM Ben Lesh notifications@github.com wrote:

Find a way to include the RxJS license

Is this to say that the new packages are missing the LICENSE file?...
that's not good. lol

I'll take care of all of the todos except the last one for now.
@robwormald https://github.com/robwormald do you want to try to correct
the license issue upstream and convince @Blesh https://github.com/blesh
to cut another RxJS release?

The beta release is coming this week (hopefully in a couple of days). Does
it need to be before that?


Reply to this email directly or view it on GitHub
#5288 (comment).

@jeffbcross
Copy link
Contributor

Bundle size measurements (using the reported numbers from gulp bundles.js.checksize for gzip level 2 as well as running gzip --best -c dist/build/angular2.min.js > dist/build/angular2.min.js.gz for gzip level 9).

variant gzip level 2 (bytes) gzip level 9 (bytes)
with no operators 153,670 118,022
with 8 operators* 160,233 123,755
difference from bare -5563 -5733
with 4 operators** 156303 120,250
difference from bare -2633 -2228

*these are the operators included in the "8 operators"

import 'rxjs/operators/map';
import 'rxjs/operators/mergeMap'; //aka flatMap
import 'rxjs/operators/filter';
import 'rxjs/operators/reduce';
import 'rxjs/operators/toPromise';

import 'rxjs/observable/from';
import 'rxjs/observable/fromArray'; //Observable.of
import 'rxjs/observable/fromPromise';

**these are the operators included in the "4 operators"

import 'rxjs/operators/map';
import 'rxjs/operators/mergeMap'; //aka flatMap
import 'rxjs/operators/filter';
import 'rxjs/operators/reduce';

CC @IgorMinar

@benlesh
Copy link
Contributor

benlesh commented Dec 1, 2015

FWIW, Observable.of and Observable.from are part of the Observable spec.

@jeffbcross jeffbcross mentioned this pull request Dec 1, 2015
7 tasks
@jeffbcross
Copy link
Contributor

FYI I opened #5533 to fix some of the remaining issues here (everything except the license issue)

@jeffbcross jeffbcross closed this Dec 1, 2015
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: review The PR is still awaiting reviews from at least one requested reviewer cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants