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

RxJS "pipeable" operators support #69

Closed
paulpdaniels opened this issue Feb 6, 2018 · 5 comments
Closed

RxJS "pipeable" operators support #69

paulpdaniels opened this issue Feb 6, 2018 · 5 comments

Comments

@paulpdaniels
Copy link

paulpdaniels commented Feb 6, 2018

RxJS now supports "pipeable" operators, it might make sense to support passing in the operator references through the Rx object bag during initialization, and then fallback to looking on the prototype. That might also make it easier to support other Observable implementations by letting the library users pass in adapter functions for their particular flavor of Observable. Areas like here

@pinghe
Copy link

pinghe commented Mar 12, 2018

Understanding Operator Imports
https://www.learnrxjs.io/concepts/operator-imports.html

@Shyam-Chen
Copy link

Shyam-Chen commented Mar 18, 2018

// rxjs v6.0.0
import { of } from 'rxjs';
import { filter, map, reduce } from 'rxjs/operators';

of(2, 'foo', 5, 'bar', 10)
  .pipe(  // pipeable is here
    filter(value => !isNaN(value)),
    map(value => value * 2),
    reduce((acc, value) => acc + value, 0)
  )
  .subscribe(value => console.log(value));
  // 34

@doliver3
Copy link

This doesn't look like full RXJS 6.0 support yet. Could you document how to use vue-rx with RXJS 6 without the rxjs-compat layer?

https://docs.google.com/document/d/12nlLt71VLKb-z3YaSGzUfx6mJbc34nsMXtByPUN35cg/edit

@paulpdaniels
Copy link
Author

Well it doesn't look like that many operators are actually used. So maybe it would be easier than I thought.

My thought was that instead of using the global Rx instead pass around a _RxLike, then support packages that define an adapter for the particular library (this is off the top of my head, if we agree to this approach I'll do some more due diligence on the exact syntax and required operators):

// For RxJS 6
import {share} from 'rxjs/operators/share'

const adapter = {
  create: observer => new Observable(observer),
  share
};

// For RxJS 5
import {Observable} from 'rxjs/Observable'
import 'rxjs/add/operator/share'

const adapter = {
  create: Observable.create,
  share: source => source.share()
};

// In createObservableMethod
// operator creation is hidden behind the adapter.
const {create, share} = adapter;
return share(create(creator));

We could also add development flags to run a check on the provided object bag to make sure that necessary features are included.

@regou
Copy link
Collaborator

regou commented Jun 2, 2018

#83

@regou regou closed this as completed Jun 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants