Skip to content
This repository was archived by the owner on Jun 1, 2024. It is now read-only.

Observable class vs builders #10

Open
alexandru opened this issue Mar 1, 2018 · 7 comments · May be fixed by #12
Open

Observable class vs builders #10

alexandru opened this issue Mar 1, 2018 · 7 comments · May be fixed by #12
Assignees

Comments

@alexandru
Copy link
Member

From what I understand Observable has static methods in it. Maybe those static methods should not be described on the Observable class.

Maybe we need an Observables object (not class).

Here's the point at which we need to investigate what other libraries are doing:

  1. latest master on https://github.com/Reactive-Extensions/RxJS
  2. https://github.com/cujojs/most

I see for example that most works with plain functions. Maybe that's not bad at all.

I mean I can see people doing this:

import * as Mx from "monix-reactive"

const stream: Mx.Observable<number> = Mx.intervalAtFixedRate(1000)
@alexandru
Copy link
Member Author

The advantage of using plain functions, btw, is that it's easier to minify the code with tools such as Webpack / Rollup. Because these minifiers are pretty dumb and work at the import level.

But then not everybody works with Google Closure and the interoperability of that with TypeScript definitions is experimental anyway.

And I have a feeling that an Observable class would get large.

@sledorze
Copy link

sledorze commented Mar 1, 2018

@alexandru from memory: Class methods and functions do not have the same variance behaviour.
So the would maybe help to make a decision.
(The former are bivariants while the later are more what you would expect .. I guess )

@lostintime
Copy link
Collaborator

@sledorze that changed from version 2.6 in --strict mode

Under --strictFunctionTypes function type parameter positions are checked contravariantly instead of bivariantly.

@lostintime
Copy link
Collaborator

As in monix Observable operators and builders also share same namespace within Observable class we can export all together from monix-reactive package too, just like in your example:

import * as Mx from "monix-reactive"

const stream: Mx.Observable<number> = Mx.intervalAtFixedRate(1000).pipe(Mx.map(_ => _ * 2))

Going to try that and see how it looks.

@sledorze
Copy link

sledorze commented Mar 1, 2018

@lostintime that changed for functions only (not class methods)

@lostintime
Copy link
Collaborator

@sledorze looks like I missed that, it's mentioned just below the quote I used :) Thanks!

@sledorze
Copy link

sledorze commented Mar 2, 2018

Devil .. :)

@lostintime lostintime self-assigned this Mar 6, 2018
@lostintime lostintime linked a pull request Mar 6, 2018 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants