* Simulate a setup node overriding the source to evaluate. * @param {string} code the Python code to evaluate. * @param {boolean} asRunButtonAction invoke the `Run` button handler. * @returns {Promise<...>} fulfill once code has been evaluated.
(code, asRunButtonAction = false)
| 392 | * @returns {Promise<...>} fulfill once code has been evaluated. |
| 393 | */ |
| 394 | value(code, asRunButtonAction = false) { |
| 395 | if (asRunButtonAction) return listener(); |
| 396 | const wasSetup = isSetup; |
| 397 | const wasSource = source; |
| 398 | isSetup = true; |
| 399 | source = code; |
| 400 | const restore = () => { |
| 401 | isSetup = wasSetup; |
| 402 | source = wasSource; |
| 403 | }; |
| 404 | return context |
| 405 | .handleEvent({ currentTarget: null }) |
| 406 | .then(restore, restore); |
| 407 | }, |
| 408 | }, |
| 409 | }); |
| 410 |