From df1acd74248dd0523867643e52d740d571492096 Mon Sep 17 00:00:00 2001 From: Gino Bustelo Date: Fri, 18 Dec 2015 14:24:06 -0600 Subject: [PATCH] Modified example to use urth-core-function (c) Copyright IBM Corp. 2015 --- .../urth-core-behaviors/execution-complete-behavior.html | 4 ++-- etc/examples/standalone/index.html | 4 ++++ etc/examples/standalone/src/index.js | 6 +++++- etc/examples/standalone/widget_code.json | 6 +++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/elements/urth-core-behaviors/execution-complete-behavior.html b/elements/urth-core-behaviors/execution-complete-behavior.html index a3fb028a..e060fedc 100644 --- a/elements/urth-core-behaviors/execution-complete-behavior.html +++ b/elements/urth-core-behaviors/execution-complete-behavior.html @@ -16,7 +16,7 @@ console.debug("Registering _onExecutionComplete for Execute Reply messages."); this.__replyCallback = this._onExecutionComplete.bind(this); - IPython.notebook.kernel.widget_manager.notebook.events.on( + IPython.notebook.events.on( 'shell_reply.Kernel', this.__replyCallback ); }, @@ -24,7 +24,7 @@ detached: function() { console.debug("Unregistering _onExecutionComplete for Execute Reply messages."); if (this.__replyCallback){ - IPython.notebook.kernel.widget_manager.notebook.events.off( + IPython.notebook.events.off( 'shell_reply.Kernel', this.__replyCallback ); } diff --git a/etc/examples/standalone/index.html b/etc/examples/standalone/index.html index f6dc1e0e..95e794fd 100644 --- a/etc/examples/standalone/index.html +++ b/etc/examples/standalone/index.html @@ -40,6 +40,10 @@
diff --git a/etc/examples/standalone/src/index.js b/etc/examples/standalone/src/index.js index 28a8f285..55570c82 100644 --- a/etc/examples/standalone/src/index.js +++ b/etc/examples/standalone/src/index.js @@ -52,6 +52,10 @@ document.addEventListener("DOMContentLoaded", function(event) { // Run backend code to create the widgets. You could also create the // widgets in the frontend, like the other /web/ examples demonstrate. - kernel.execute({ code: code }); + var execPromise = kernel.execute({ code: code }); + execPromise.onReply = function(){ + IPython.notebook.events.trigger('shell_reply.Kernel'); + } + }); }); diff --git a/etc/examples/standalone/widget_code.json b/etc/examples/standalone/widget_code.json index e95cd3f7..f56afa1c 100644 --- a/etc/examples/standalone/widget_code.json +++ b/etc/examples/standalone/widget_code.json @@ -1,4 +1,8 @@ [ "from urth.widgets.widget_channels import channel", - "channel('a').set('msg', 'Hello from kernel')" + "def hello(name):", + " return 'Hello ' + name", + "channel('a').set('isready', True)" ] + +