byteface / domonic

Create HTML with python 3 using a standard DOM API. Includes a python port of JavaScript for interoperability and tons of other cool features. A fast prototyping library.
https://domonic.readthedocs.io/
MIT License
129 stars 13 forks source link

Implement Global.setTimeout #23

Closed Jordan-Cottle closed 2 years ago

Jordan-Cottle commented 2 years ago

This should be a working implementation for setTimeout and clearTimeout as mentioned in #11.

I'm not familiar enough with the project to know how to integrate it with SetInterval mentioned in the issue, but threading.Timer is a python builtin that provides pretty much exactly the same functionality as setTimeout and clearTimeout does in javascript.

I've also added two tests for this. One that checks that the callback is actually called, and the other that checks that a callback can be canceled properly.

byteface commented 2 years ago

This is incredible!!! thanks so much. I thought after doing setInterval it was going to take me ages and hadn't realised you could just do that with a threading.Timer. This is pretty major as those 2 methods are ones people know. I'm noticing 90% of the methods I'm porting I didn't even realise existed. But everyone knows those 2 so they've been on my radar for months now. I wlil try to sort these into a release today. I'm hugely grateful.

byteface commented 2 years ago

thanks again. this is now in 0.4.7 . great work. two .js classics now available in python