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: smallify all the things #5729

merged 140 commits into from Sep 23, 2020


Copy link

@benlesh benlesh commented Sep 13, 2020

Going through, operator by operator, and making them smaller. Centralizing on a new type called OperatorSubscriber that enables most behaviors fairly cleanly and concisely.

Will show stats when finished.

Progress Update 9/17



AFTER: 59KB (63% of the original size)
AFTER: 57KB (61% of the original size)


Review Checklist:

Reviewed files:

Check only files that have been reviewed and have no issues. If there are issues with a review, add a link to the review to the listed file.

benlesh added 30 commits Sep 11, 2020
- Smaller implementation
- Improved docs
- Adds comments
- Adds a test
- Fixes weird adjustment in `reduce`.

Closes ReactiveX#4348
Closes ReactiveX#3879
- Refactor to make it smaller
- Replaced a faulty test with a test that tests the same thing. Verified the behavior has not changed since 6.x.
- Centralize all try/catching for next calls.
- Uses OperatorSubscriber
- Much smaller
- Smaller implementation
- Uses OperatorSubscriber
- Removes runtime assertions
- Adds supporting features to OperatorSubscriber
…new window when old one closes

This was a long-broken bit of functionality, but windowTime was so little used, I chose to ignore it. With this change, we could make `bufferTime` based off of `windowTime` and `toArray`.
Copy link
Member Author

benlesh commented Sep 22, 2020

@cartant and @jayphelps ... I think I've addressed all of your comments.

I've unified on an approach for freeing up resources like buffered values, I think... basically, a returned function from the lift is a terse way to add a teardown to the destination subscriber. This ensures that the resource will be freed regardless of source (or inner) completion or error, or destination unsubscription. It could delay the release of those resources in some cases, so things will still have to be addressed on a case-by-case basis. But over all it looks like this:

return (source: Observable<T>) => lift(source, function(this: Subscriber<R>, source: Observable<T>) {
   const subscriber = this;
   /* stuff here */

   // Additional teardown
   return () => {
      buffer = null!

This is equivalent to making the last line: subscriber.add(() => buffer = null!).

src/internal/operators/retryWhen.ts Outdated Show resolved Hide resolved
src/internal/operators/groupBy.ts Outdated Show resolved Hide resolved
src/internal/Subject.ts Outdated Show resolved Hide resolved
Copy link

@cartant cartant left a comment


@benlesh benlesh merged commit fc41e13 into ReactiveX:master Sep 23, 2020
@cartant cartant changed the title WIP: Refactor/smallify all the things refactor: smallify all the things Sep 23, 2020
jakovljevic-mladen added a commit to jakovljevic-mladen/rxjs that referenced this pull request Sep 28, 2020
jakovljevic-mladen added a commit to jakovljevic-mladen/rxjs that referenced this pull request Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

7 participants