rx-jupyter
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -6,2 +6,5 @@ "use strict"; | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
exports.list = list; | ||
@@ -22,2 +25,6 @@ exports.get = get; | ||
var _Subject = require("rxjs/Subject"); | ||
var _Subscriber = require("rxjs/Subscriber"); | ||
var _base = require("./base"); | ||
@@ -129,3 +136,35 @@ | ||
function connect(serverConfig, kernelID, sessionID) { | ||
return (0, _webSocket.webSocket)(formWebSocketURL(serverConfig, kernelID, sessionID)); | ||
var wsSubject = (0, _webSocket.webSocket)(formWebSocketURL(serverConfig, kernelID, sessionID)); | ||
// Create a subject that does some of the handling inline for the session | ||
// and ensuring it's serialized | ||
return _Subject.Subject.create(_Subscriber.Subscriber.create({ | ||
next: function next(message) { | ||
if (typeof message === "string") { | ||
// Assume serialized | ||
wsSubject.next(message); | ||
} else if ((typeof message === "undefined" ? "undefined" : _typeof(message)) === "object") { | ||
var sessionizedMessage = Object.assign({}, message, { | ||
header: Object.assign({}, { | ||
session: sessionID | ||
}, message.header) | ||
}); | ||
wsSubject.next(JSON.stringify(sessionizedMessage)); | ||
} else { | ||
console.error("Message must be a string or object, app sent", message); | ||
} | ||
}, | ||
error: function error(e) { | ||
return wsSubject.error(e); | ||
}, | ||
complete: function complete() { | ||
return wsSubject.complete(); | ||
} | ||
}), // Subscriber | ||
// Subject.create takes a subscriber and an observable. We're only overriding | ||
// the subscriber here so we pass the subject on as an observable as the | ||
// second argument to Subject.create (since it's _also_ an observable) | ||
// $FlowFixMe: update the flow definition to allow this | ||
wsSubject); | ||
} |
{ | ||
"name": "rx-jupyter", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "RxJS 5 bindings for the Jupyter Notebook API", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -7,2 +7,5 @@ // @flow | ||
import { Subject } from "rxjs/Subject"; | ||
import { Subscriber } from "rxjs/Subscriber"; | ||
import { createAJAXSettings } from "./base"; | ||
@@ -131,4 +134,43 @@ | ||
sessionID: ?string | ||
): Observable<*> { | ||
return webSocket(formWebSocketURL(serverConfig, kernelID, sessionID)); | ||
): * { | ||
const wsSubject = webSocket( | ||
formWebSocketURL(serverConfig, kernelID, sessionID) | ||
); | ||
// Create a subject that does some of the handling inline for the session | ||
// and ensuring it's serialized | ||
return Subject.create( | ||
Subscriber.create({ | ||
next: message => { | ||
if (typeof message === "string") { | ||
// Assume serialized | ||
wsSubject.next(message); | ||
} else if (typeof message === "object") { | ||
const sessionizedMessage = Object.assign({}, message, { | ||
header: Object.assign( | ||
{}, | ||
{ | ||
session: sessionID | ||
}, | ||
message.header | ||
) | ||
}); | ||
wsSubject.next(JSON.stringify(sessionizedMessage)); | ||
} else { | ||
console.error( | ||
"Message must be a string or object, app sent", | ||
message | ||
); | ||
} | ||
}, | ||
error: e => wsSubject.error(e), | ||
complete: () => wsSubject.complete() | ||
}), // Subscriber | ||
// Subject.create takes a subscriber and an observable. We're only overriding | ||
// the subscriber here so we pass the subject on as an observable as the | ||
// second argument to Subject.create (since it's _also_ an observable) | ||
// $FlowFixMe: update the flow definition to allow this | ||
wsSubject | ||
); | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77833
1591