Show More
@@ -0,0 +1,16 b'' | |||
|
1 | * Added a widget persistence API. This allows you to persist your notebooks interactive widgets. | |
|
2 | Two levels of control are provided: | |
|
3 | 1. Higher level- ``WidgetManager.set_state_callbacks`` allows you to register callbacks for loading and saving widget state. The callbacks are automatically called when necessary. | |
|
4 | 2. Lower level- the ``WidgetManager`` Javascript class now has ``get_state`` and ``set_state`` methods that allow you to get and set the state of the widget runtime. | |
|
5 | ||
|
6 | Example code for persisting your widget state to session data: | |
|
7 | ||
|
8 | :: | |
|
9 | %%javascript | |
|
10 | require(['widgets/js/manager'], function(manager) { | |
|
11 | manager.WidgetManager.set_state_callbacks(function() { // Load | |
|
12 | return JSON.parse(sessionStorage.widgets_state || '{}'); | |
|
13 | }, function(state) { // Save | |
|
14 | sessionStorage.widgets_state = JSON.stringify(state); | |
|
15 | }); | |
|
16 | }); No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now