You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 6, 2020. It is now read-only.
Ideally, we would expose an API in JavaScriptWorkspace that fully matches the Python API. I believe that this should be possible, although I'm not sure about the best implementation yet. We could change the current Canvas object (and others), or we could implement adapters that make these objects behave more like their Python counterparts. I looked into decorators to mimic the **style_args implementation, and it strikes me that we could do much the same in JavaScript.
In other words, I would like the following to work in an inline_javascript item.
c=newCanvas()// also acceptable: `Canvas()`c.rect(0,0,100,100,color="red")c.show()
The Python API is quite elaborate, and we wouldn't necessarily need to implement all of it immediately. But Canvas, Keyboard, and Mouse would be very useful to start with.
The text was updated successfully, but these errors were encountered:
It should mostly possible. Instead of **style_args, one could use the JavaScript spread operator ... which is only available from ES7 or something onwards.
The only culprit remains the sleep() function again. This can nowadays be solved by using async functions, but then users have to explicitly use the await keyword, i.e. await sleep(1000) to make it work, and I don't know if this can be done from inside the eval() function...
It should mostly possible. Instead of **style_args, one could use the JavaScript spread operator ... which is only available from ES7 or something onwards.
That might be an option then. If it makes life much easier, I don't mind if this comes at the expense of compatibility with older browsers, as long as we keep track of which browsers are supported.
The only culprit remains the sleep() function again. This can nowadays be solved by using async functions, but then users have to explicitly use the await keyword, i.e. await sleep(1000) to make it work, and I don't know if this can be done from inside the eval() function...
I was thinking about that too. Let's be pragmatic here, and focus on those things that are 1) doable and 2) useful. The clock object may only satisfy 2.
Ideally, we would expose an API in
JavaScriptWorkspace
that fully matches the Python API. I believe that this should be possible, although I'm not sure about the best implementation yet. We could change the currentCanvas
object (and others), or we could implement adapters that make these objects behave more like their Python counterparts. I looked into decorators to mimic the**style_args
implementation, and it strikes me that we could do much the same in JavaScript.In other words, I would like the following to work in an
inline_javascript
item.The Python API is quite elaborate, and we wouldn't necessarily need to implement all of it immediately. But
Canvas
,Keyboard
, andMouse
would be very useful to start with.The text was updated successfully, but these errors were encountered: