Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is < 10 operations considered a failure for Exercise 13? #192

Open
RavenHursT opened this issue Apr 12, 2018 · 0 comments
Open

Why is < 10 operations considered a failure for Exercise 13? #192

RavenHursT opened this issue Apr 12, 2018 · 0 comments

Comments

@RavenHursT
Copy link

RavenHursT commented Apr 12, 2018

The solution does sets an odd, arbitrary threshold for releasing control to the event loop:

https://github.com/timoxley/functional-javascript-workshop/blob/master/exercises/blocking_event_loop/solution/solution.js#L6-L9

This arbitrary assumption is coded into the test runner for this exercise, tightly coupling the two:
https://github.com/timoxley/functional-javascript-workshop/blob/master/exercises/blocking_event_loop/wrapper.js#L34-L37

But wrapping execution of the operation function and recursive call in a setImmediate will allow the EventLoop itself handle the scheduling. It seems rather bad practice to try to control scheduling of the EventLoop within the application layer.

https://repl.it/@RavenHursT/Functional-JS-Workshop-Exercise-13-Solution

In the end, the exercise was to write non-blocking code. Even if the callback only fires once, before the EventLoop schedules the interrupt, then the test should pass because the goal of the exercise was accomplished (learn how to release control to the EventLoop).

For further reference: https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/

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

No branches or pull requests

1 participant