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

Documentation (in particular Observable.webSocket) #2193

Open
timjacobi opened this issue Dec 13, 2016 · 12 comments
Open

Documentation (in particular Observable.webSocket) #2193

timjacobi opened this issue Dec 13, 2016 · 12 comments
Labels
docs Issues and PRs related to documentation help wanted Issues we wouldn't mind assistance with.

Comments

@timjacobi
Copy link

timjacobi commented Dec 13, 2016

Hi Guys,

First of all congrats on releasing the final version, I appreciate the work everyone has put into this project as I've been closely following. Now that the final version is released I was hoping to find some more complete API documentation. In this case I was looking to create an observable from web sockets.

I went to the API docs which tell me I need to pass urlConfigOrSource but I could not figure out how to set it up, am I missing something?
Moving on Observable.webSocket returns a WebSocketSubject so I tried to find out how to use it. All the API docs tell me is We need this JSDoc comment for affecting ESDoc.

Just to compare Observable.fromPromise has a neat little example that tells me how to use it.

I would really like to fully start using RxJS 5 when we build our next product but the lack of documentation prevents us from doing so. If we were to use it then I'm sure we would also contribute if we find bugs as we go along.

Am I missing an important piece here?
Are there any examples elsewhere?
How can I get involved to help improving the docs?

Again thanks for this great library.

@kwonoj
Copy link
Member

kwonoj commented Dec 13, 2016

Yes, while it is released version it still lacks some of the documentation in detail, need to be improved over time. If you're using TypeScript in codebases, most of type comes with the inference that you can get it immediately (i.e config interface you mentioned: https://github.com/ReactiveX/rxjs/blob/master/src/observable/dom/WebSocketSubject.ts#L13) but that isn't applicable for all cases since it's TypeScript only.

For now, if you find some of docs are missing and looking for concise examples of code snippet, unit test in repo provides immediate workarounds. For example, you can find several approach of constructing websocketsubject in test case (https://github.com/ReactiveX/rxjs/blob/master/spec/observables/dom/webSocket-spec.ts#L226) with its usages.

It is hugely appreciated to have contribution to improve document - first you can check general contribution guideline here (https://github.com/ReactiveX/rxjs/blob/master/CONTRIBUTING.md) and use other documented codebase as reference (https://github.com/ReactiveX/rxjs/blob/master/src/operator/filter.ts for example).

@benlesh
Copy link
Member

benlesh commented Dec 13, 2016

The bottom line here is that we need to add documentation around WebSocketSubject. Thanks @timjacobi for bringing this back to our attention. I think we should prioritize documentation as well.

@timjacobi
Copy link
Author

@kwonoj Thanks for pointing out the tests, I was actually able to infer a lot of stuff from there 👍

@jrgleason
Copy link

It would be nice if we could add more details about how to test this too. I looked at https://github.com/ReactiveX/rxjs/blob/9b428d7778ae8ac35c729e66a238ce97698a252e/spec/observables/dom/webSocket-spec.ts but I couldn't really figure it out.

@kwonoj kwonoj added docs Issues and PRs related to documentation help wanted Issues we wouldn't mind assistance with. labels Mar 1, 2017
@luillyfe
Copy link
Contributor

Hi guys, any advance in this topic ? because I got a proposal, it is pretty straightforward (a news feed) but it shows a real use case where we can use websocket subject.

https://github.com/luillyfe/rxjs-websockets/tree/features/news-feed.

Reviews so Welcome!

@luillyfe
Copy link
Contributor

Here I come with Multiplexing example (It has News and Chat),

https://github.com/luillyfe/rxjs-websockets/tree/features/multiplexing

I want to hear your opinions.

@luillyfe
Copy link
Contributor

@dalu not sure what you mean by that. Do you mind to explain it a little better ?

@inf3cti0n95
Copy link
Contributor

@dalu in the multiplex() method, for message filter the filter function should return a Boolean value (true or false). returning True will result in message to pass and return false would filter out the message.

I suggest if you need to have a filter to have no messages to be passed, try out

() => false

I hope this makes it clear.

inf3cti0n95 added a commit to inf3cti0n95/rxjs that referenced this issue Feb 2, 2019
Removed ambiguous explaination of the messageFilter function

ReactiveX#2193
@inf3cti0n95
Copy link
Contributor

@dalu Oops! My bad!

@inf3cti0n95
Copy link
Contributor

@dalu But then If you do not want to have that sub and unSub methods to fire, why are you even using multiplex? Can't you just use the original webSocket with a filter method? 😅

@japalo
Copy link

japalo commented Nov 7, 2019

@dalu Did you find a fix for this, or did you end up sending empty objects? I am thinking about using rxjs webSocket for a project but it feels weird to send empty objects all the time.

Is there any way of using multiplex for just listening to data being pushed instead of listening AND sending with Observable.webSocket ?

@japalo
Copy link

japalo commented Nov 8, 2019

My idea is to use a socket as a type of event listener in any case. An event from backend is triggered (with payload) and frontend responds to it depending on what type of event it is. 90% of our users are desktop users so i am kinda ok with mobile users losing connection every now and then since the main flows wont be using socket(s).

If i decide to use sockets from rxjs, will i have an issue with empty objects pushed to backed if i never trigger a Subject.next()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Issues and PRs related to documentation help wanted Issues we wouldn't mind assistance with.
Projects
None yet
Development

No branches or pull requests

7 participants