Skip to content

Master event loop correspondence #3878

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

Merged
merged 3 commits into from
Sep 12, 2020

Conversation

2Shaun
Copy link
Contributor

@2Shaun 2Shaun commented Sep 5, 2020


name: "\U0001F4D6 New/Updated Documentation Content"
about: Adding a new docs page, or updating content in an existing docs page

PR Type

Does this PR add a new page, or update an existing page?
Updates an existing page.

Checklist

  • Is there an existing issue for this PR?
  • Have the files been linted and formatted?

What docs page is being added or updated?

  • Section: Essentials
  • Page: 1

For Updating Existing Content

What updates should be made to the page?

I think there should be more emphasis on the correspondence with the familiar event loop to mitigate the terminology learning curve.

Do these updates change any of the assumptions or target audience? If so, how do they change?

They assume a newcomer to Redux, which I believe is already the target audience for this page.

@netlify
Copy link

netlify bot commented Sep 5, 2020

Deploy preview for redux-docs ready!

Built with commit 7a6411c

https://deploy-preview-3878--redux-docs.netlify.app

@markerikson
Copy link
Contributor

markerikson commented Sep 5, 2020

Hey, thanks for filing this. I know we chatted about it a bit over on Twitter.

I'm not sure I agree with some of the changes here, though.

First off, the phrase "event loop" is wrong here. I think you mean "event emitter" instead.

Second, the table really doesn't belong in the "what you've learned", because it's not recapping something that was already taught earlier in the page.

Third, if anything, I feel like this maybe goes a bit more in the "data flow" section.

@2Shaun
Copy link
Contributor Author

2Shaun commented Sep 5, 2020

Assuming you were to agree with the change, do you think the reducer comparison belongs here? It seemed to fit with the other bolded comparisons in the doc.

As for the table placement, I agree with what you're saying. Honestly, the 'event loop' phrase choice came from a quick web search that returned this Wikipedia article, which seemed to describe a generic model for events. I can push with 'event emitter' used instead, but I'd have to reread the "data flow" section to figure out placement.

@markerikson
Copy link
Contributor

The phrase "event loop" specifically refers to a tight while loop where a central driver application pulls events off a FIFO queue and executes them. Concrete examples of this are the Win32 event loop (handled by WndProc functions in user app code), or in the JS world, the JS interpreter loop where every DOM event, timer event, etc is handled by adding events to the queue and executing them sequentially.

One of the best explanations of this is the talk "What is the event loop, anyway?", which walks through how the JS event loop works.

This is a completely different than an event emitter, where arbitrary parts of an app can subscribe to some future event, and the emitter object runs all listeners when that event is triggered.

At the moment, I think I'm inclined to leave that "reducer" sentence alone, but just drop the table.

@2Shaun
Copy link
Contributor Author

2Shaun commented Sep 11, 2020

@markerikson Have you thought about this any further? I think it would help to relate the reducer to something familiar for new comers.

By the way, I did watch that talk and the event loop task queue definitely cleared up a couple of bugs I've had in the past.

@markerikson
Copy link
Contributor

Sure, this works.

@markerikson markerikson merged commit 7cc8442 into reduxjs:master Sep 12, 2020
alokreddy pushed a commit to alokreddy/redux that referenced this pull request Sep 30, 2020
* Add event listener analogy and event loop correspondence table

* Remove header cell

* Drop table
webMasterMrBin pushed a commit to webMasterMrBin/redux that referenced this pull request Aug 21, 2021
* Add event listener analogy and event loop correspondence table

* Remove header cell

* Drop table

Former-commit-id: 832d4b4
Former-commit-id: b8aba47
webMasterMrBin pushed a commit to webMasterMrBin/redux that referenced this pull request Aug 21, 2021
* Add event listener analogy and event loop correspondence table

* Remove header cell

* Drop table

Former-commit-id: 832d4b4
Former-commit-id: b8aba47
webMasterMrBin pushed a commit to webMasterMrBin/redux that referenced this pull request Aug 21, 2021
* Add event listener analogy and event loop correspondence table

* Remove header cell

* Drop table

Former-commit-id: 832d4b4
Former-commit-id: b8aba47
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.

2 participants