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

Socket + JsonSocket + RxJs = No Love #31

Open
aleffsouza opened this issue Dec 2, 2016 · 1 comment
Open

Socket + JsonSocket + RxJs = No Love #31

aleffsouza opened this issue Dec 2, 2016 · 1 comment

Comments

@aleffsouza
Copy link

I'm using Nodejs' core sockets to send some Json files, the code bellow is just the server connection handler and when this code run I've got a weird exception that sounds like JsonSocket doesn't have a 'data' or 'error' events. Have you had this kind of problem before?

const { Observable } = require('rxjs/Rx')

socket = new JsonSocket(socket)

function createSocketObservable(event) {
  return Observable.fromEvent(socket, event)
}

const SocketDataObservable = createSocketObservable('data')
const SocketErrorObservable = createSocketObservable('error')

SocketDataObservable
  .takeUntil(SocketErrorObservable, handleSocketError)
  .subscribe((data) => console.log("DATA", data))
...\node_modules\rxjs\Subscriber.js:227
            throw err;
            ^

TypeError: Invalid event target
    at Function.FromEventObservable.setupSubscription (...\node_modules\rxjs\observable\FromEventObservable.js:108:19)
    at FromEventObservable._subscribe (...\node_modules\rxjs\observable\FromEventObservable.js:130:29)
    at FromEventObservable.Observable.subscribe (...\node_modules\rxjs\Observable.js:45:27)
    at Object.subscribeToResult (...\node_modules\rxjs\util\subscribeToResult.js:21:27)
    at new TakeUntilSubscriber (...\node_modules\rxjs\operator\takeUntil.js:65:38)
    at TakeUntilOperator.call (...\node_modules\rxjs\operator\takeUntil.js:51:34)
    at Observable.subscribe (...\node_modules\rxjs\Observable.js:42:22)
    at handleServerConnection (The function above!!!)
    at tryCatcher (...\node_modules\rxjs\util\tryCatch.js:6:31)
    at Server.<anonymous> (...\node_modules\rxjs\observable\FromEventObservable.js:122:56)
    at emitOne (events.js:96:13)
    at Server.emit (events.js:188:7)
    at TCP.onconnection (net.js:1459:8)
@sebastianseilund
Copy link
Owner

Can you paste a full code example? Where does socket come from above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants