Skip to content

Conversation

@Xmader
Copy link
Member

@Xmader Xmader commented Jul 12, 2023

  • Rewrite setTimeout/clearTimeout in JS with C++ internal bindings, cleaner code
  • Support passing a code string to setTimeout as the callback function
  • setInterval/clearInterval (separate PR)
  • queueMicrotask (separate PR)

@Xmader Xmader force-pushed the Xmader/feat/better-setTimeout branch from 6dc3d4c to 0f990f1 Compare July 12, 2023 20:50
Base automatically changed from Xmader/feat/atob-btoa to main July 13, 2023 20:51
@zollqir zollqir mentioned this pull request Jul 19, 2023
@wesgarland
Copy link
Collaborator

What is preventing this branch from landing? Just review from @caleb-distributive ?

@Xmader
Copy link
Member Author

Xmader commented Jul 29, 2023

It's missing setInterval/clearInterval

@Xmader Xmader added this to the v0.3.0 milestone Aug 2, 2023
@Xmader
Copy link
Member Author

Xmader commented Aug 2, 2023

It's missing setInterval/clearInterval

To make this pull request land sooner, I decided to split it into separate PRs.

@Xmader Xmader force-pushed the Xmader/feat/better-setTimeout branch from c6bf140 to 4b5cfab Compare August 2, 2023 05:37
@Xmader Xmader marked this pull request as ready for review August 2, 2023 05:37
@Xmader Xmader requested review from wesgarland and zollqir August 2, 2023 23:14

// Schedule job to the running Python event-loop
PyEventLoop loop = PyEventLoop::getRunningLoop();
if (!loop.initialized()) return false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we set an exception here?

Copy link
Member Author

@Xmader Xmader Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.
We've had already thrown an exception inside PyEventLoop::getRunningLoop()
https://github.com/Distributive-Network/PythonMonkey/blob/4da2838/src/PyEventLoop.cc#L76-L77

@Xmader Xmader requested a review from zollqir August 4, 2023 20:02
Copy link
Collaborator

@wesgarland wesgarland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work - can't wait to see this land

'vars-on-top': [ 'error' ],
'no-var': [ 'off' ],
'spaced-comment': [ 'warn' ],
'brace-style': [ 'off' ],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this will generate false positives on code which acceptable per DCP JS coding style. Not really a big deal unless you want to never have spurious warnings. One of the core team members apparently made an es-lint plug-in that understands this, but I haven't reviewed it.

DCP bracing style is

  • allman style for flow control and function declaration
  • k&r style for object and function literals
  • literal braces always followed by ; or ,
  • top-level assignment to function literal in allman style, eg. module exports property assignments

This is a good style for reading but a hard style for linting.

@zollqir zollqir merged commit 7aadec4 into main Aug 10, 2023
@Xmader Xmader deleted the Xmader/feat/better-setTimeout branch August 10, 2023 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants