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

Move rxjs/add/* modules to a separate package for 6.0? #2913

Closed
benlesh opened this issue Oct 6, 2017 · 11 comments
Closed

Move rxjs/add/* modules to a separate package for 6.0? #2913

benlesh opened this issue Oct 6, 2017 · 11 comments

Comments

@benlesh
Copy link
Member

benlesh commented Oct 6, 2017

Most of us are in agreement that we'd advise people use the pipeable operators instead of the prototype patching for a variety of reasons that have been outlined elsewhere.

Do we want to keep the rxjs/add/* modules in the same package as everything else, or do we want to have a separate package to support dot-chaining on NPM?

Or... more extreme... should we eliminate them? Maybe even wait for v 7 for that?

Either way, how could we best educate people of the caveats?

@benlesh
Copy link
Member Author

benlesh commented Oct 6, 2017

@kwonoj @david-driscoll

@kwonoj
Copy link
Member

kwonoj commented Oct 6, 2017

This seems related with #2911, so in next major, dot chain operator syntax is no longer default thing? I think this discussion is really depends on those direction.

@benlesh
Copy link
Member Author

benlesh commented Oct 6, 2017

Yeah, I suppose it's related for sure. Although it doesn't really have to be... you can definitely have dot-chaining without lift.

@kwonoj
Copy link
Member

kwonoj commented Oct 6, 2017

There should be long other discussions need to be done, But first I'd downvote to eliminating it completely. It's too radical even for major breaking.

@benlesh
Copy link
Member Author

benlesh commented Oct 6, 2017

@kwonoj I think I agree. I don't think I'm down for completely eliminating it. At least not in the short to mid-term. But a separation might provide people better guidance and clarity.

@kwonoj
Copy link
Member

kwonoj commented Oct 6, 2017

yes, I'm sort of agreeing to separate packages, especially given size constraint we'd like to achieve in pkg. Either case it'll be huge breaking so through guide / migration process should be prepared.

@felixfbecker
Copy link
Contributor

A separate package could possibly have very confusing bugs with node module resolution / node_modules structure where the Observable import may not resolve to the correct version (I've hit bugs like that and they are insanely hard to debug). It would also mean it's harder to upgrade to v6 (e.g. a Greenkeeper PR won't do it). I would vote for keeping them in the main package for now and deprecate them. Then they can be removed in a future major version when most people are using lettable operators.

@benlesh
Copy link
Member Author

benlesh commented Oct 16, 2017

@felixfbecker the separate package would need to have peer-dependency requirements.

@wardpeet
Copy link

so talking to @ladyleet for a minute on slack I think I understand what you want to do.

My suggestion is to bring lerna which makes it possible to publish multiple packages from the root with the same version.

so we probably start with

  • core (all of rxjs)
  • websocket subject
  • ajax subject

@debuggerpk
Copy link

debuggerpk commented Jan 6, 2018

I am undecided if this is the right place to ask this question, or StackOverflow might be best for this. So here i go.

My introductions to rxjs was through the excellent Angular framework and throughout every tutorial and in practice has been "import whatever you need from add/operator and then chain it. eg.

import { Observable } from 'rxjs/Observable';
import { empty } from 'rxjs/observable/empty';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
// Other rxjs import
import 'rxjs/add/observable/of';

Class SomeClass {
  @Effect
  search$ = this._action
    .ofType<search.SearchCountry>(search.SEARCH_COUNTRY)
    .map(action => {
      return action.payload;
    })
    .switchMap(query => {
      if (query === '') {
        return empty();
      }
      const nextSearch$ = this._action.ofType(search.SEARCH_COUNTRY).skip(1);

      return this._searchService
        .search(query)
        .do(query => console.log(query))
        .takeUntil(nextSearch$)
        .map((result: RestResponseInterface) => {
          return new search.SearchCountryComplete(result);
        });
    })
    .catch(error => {
      return Observable.of(new search.SearchError('Undocumented API Error'));
    });
}

As explained in lettable documentaion, and If I am reading this right, chaining is discouraged as way forward, and pipe is the recommended implementation. The same implementation should be written as follows

import { tap, take, takeUntil, skip, map, switchMap } from 'rxjs/operators'; // Import statements have changed

search$ = this._action
	.pipe(
		ofType<search.SearchCountry>(search.SEARCH_COUNTRY),
		map(action => action.payload),
		switchMap(query => {
			if (query === '') {
				return empty();
			}

			const nextSearch$ = this._action.ofType(search.SEARCH_COUNTRY).skip(1);

			return this._searchService
				.search(query)
				.pipe(tap(qyery => console.log(query)), takeUntil(nextSearch$), map((result: RestResponseInterface) => new search.SearchCountryComplete(result)));
		})
	)
	.catch(error => {
		return Observable.of(new search.SearchError('Undocumented API Error'));
	});

Because when i read the source, especially after https://github.com/ReactiveX/rxjs/blob/master/src/Rx.ts#L41 its seems that chaining is perfectly acceptable, however this proposal is discussing adding rxjs/add/* as a seperate package.

My question is, how will this effect chaining in future?

@benlesh
Copy link
Member Author

benlesh commented Sep 26, 2018

This is done. We effectively did this with rxjs-compat.

@benlesh benlesh closed this as completed Sep 26, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Oct 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants