<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: dean glükler</title>
    <description>The latest articles on DEV Community by dean glükler (@deanglukler).</description>
    <link>https://dev.to/deanglukler</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1120393%2F31f01ea0-1f24-4c19-b290-4ec4b4ed6390.jpeg</url>
      <title>DEV Community: dean glükler</title>
      <link>https://dev.to/deanglukler</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/deanglukler"/>
    <language>en</language>
    <item>
      <title>An OOP sudocode representation of the JS event loop</title>
      <dc:creator>dean glükler</dc:creator>
      <pubDate>Sat, 15 Jul 2023 18:19:14 +0000</pubDate>
      <link>https://dev.to/deanglukler/an-oop-sudocode-representation-of-the-js-event-loop-33no</link>
      <guid>https://dev.to/deanglukler/an-oop-sudocode-representation-of-the-js-event-loop-33no</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class EventLoop {
    constructor() {
        this.latestRenderTime = Date.now();
        this.taskQueue = [];
        this.requestAnimQueue = [];
    }

    begin() {
        while (1) {
            this.theLoop();
        }
    }

    theLoop() {
        this.processTask();

        this.processAllMicroTasks();

        // render if it's been over 60 ms (refresh screen)
        if (Date.now() - this.latestRenderTime &amp;gt;= 60) {
            this.processAllRequestAnimationTasks();
            this.renderSteps();
        }
    }

    processTask() {
        // process one tasks (if exists) until completion
    }

    processAllRequestAnimationTasks() {
        // process all request animation frame callbacks that exist
        // if new requestAnimationFrame callbacks are declared, queue them for next frame
    }

    processAllMicroTasks() {
        // process all microTasks
        // if new microtasks, add them to stack and process until finished
        // this can block rendering
    }

    renderSteps() {
        // in browser land..
        // do style calculation
        // do layout render tree
        // paint pixel data
        this.latestRenderTime = Date.now();
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>oop</category>
    </item>
  </channel>
</rss>
