-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
Is Socket derived from EventEmitter? #199
Comments
Yes, it inherits from |
We use this library with RxJS in @nteract by using export function createObservable(socket) {
return fromEvent(socket, "message").pipe(
map(msg => {
// Conform to same message format as notebook websockets
// See https://github.com/n-riesco/jmp/issues/10
delete msg.idents;
return msg;
}),
publish(),
refCount()
);
} Since we use it in two directions, we also create a subscriber like this: export function createSubscriber(socket) {
return Subscriber.create({
next: messageObject => {
socket.send(new jmp.Message(messageObject));
},
complete: () => {
// tear it down, tear it *all* down
socket.removeAllListeners();
socket.close();
}
});
} And then form a export function createSubject(socket) {
const subj = Subject.create(
createSubscriber(socket),
createObservable(socket)
);
return subj;
} By the sound of it, I think this means that the typescript definition is not completely accurate. Where do you get it from? |
Thank you for your answers, I think that my problem lies in the TS definition file from |
The latest 6.0 beta release is written in TypeScript so there should no longer be a mismatch in the type definitions. It would be great if you could try it out! The new version has a new API that addresses some fundamental issues with the previous API, but it does include a compatibility layer that should make upgrading easier. See #189 for the reasoning behind the new API. If you run into any problems feel free to report it here or in a new issue. |
Hi,
In Node.js, Socket is derived from EventEmitter, which enables one to use Rx.Observable.fromEvent() on Socket objects.
Afaik, it does not seem to be the case in 0MQ, at least in the TypeScript declaration file.
Am I wrong? Would it be complicated to have Socket derive from EventEmitter (as claimed in the book of Jim Wilson) ?
Otherwise, how can one make an Rx.Observable from a zmq.Socket ?
Thank you.
The text was updated successfully, but these errors were encountered: