File tree 2 files changed +16
-3
lines changed
api/src/main/kotlin/org/jetbrains/kotlinx/jupyter/api
lib/src/main/kotlin/jupyter/kotlin
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,14 @@ class MimeTypedResult(
127
127
result.setDisplayId(id)
128
128
return Json .encodeToJsonElement(result) as JsonObject
129
129
}
130
+
131
+ /* *
132
+ * Adds an [id] to this [MimeTypedResult] object
133
+ */
134
+ @Suppress(" unused" )
135
+ fun withId (id : String? ): MimeTypedResult {
136
+ return MimeTypedResult (mimeData, isolatedHtml, id)
137
+ }
130
138
}
131
139
132
140
// Convenience methods for displaying results
Original file line number Diff line number Diff line change 1
1
package jupyter.kotlin
2
2
3
+ import org.jetbrains.kotlinx.jupyter.api.KotlinKernelHost
3
4
import org.jetbrains.kotlinx.jupyter.api.Notebook
4
5
import org.jetbrains.kotlinx.jupyter.api.ResultsAccessor
5
6
import org.jetbrains.kotlinx.jupyter.api.libraries.CodeExecution
@@ -10,11 +11,15 @@ abstract class ScriptTemplateWithDisplayHelpers(
10
11
val notebook : Notebook ,
11
12
private val hostProvider : KotlinKernelHostProvider
12
13
) {
13
- fun DISPLAY ( value : Any ) = hostProvider.host!! .display(value)
14
+ private val host : KotlinKernelHost get( ) = hostProvider.host!!
14
15
15
- fun EXECUTE ( code : String ) = hostProvider. host!! .scheduleExecution( CodeExecution (code).toExecutionCallback() )
16
+ fun DISPLAY ( value : Any ) = host.display(value )
16
17
17
- fun USE (library : LibraryDefinition ) = hostProvider.host!! .addLibrary(library)
18
+ fun UPDATE_DISPLAY (value : Any , id : String? ) = host.updateDisplay(value, id)
19
+
20
+ fun EXECUTE (code : String ) = host.scheduleExecution(CodeExecution (code).toExecutionCallback())
21
+
22
+ fun USE (library : LibraryDefinition ) = host.addLibrary(library)
18
23
19
24
fun USE (builder : JupyterIntegration .Builder .() -> Unit ) {
20
25
val o = object : JupyterIntegration () {
You can’t perform that action at this time.
0 commit comments