GithubHelp home page GithubHelp logo

asynceventdemo's Introduction

asyncEventDemo

Repo notes

Sample repo for async event handlers. This sample has pure JS ES2018 async sample in html/file2.html (+ js/file2.js) and TypeScript sample that need to be build by TypeScript in html/file1.html (+ ts/file1.js that will be delivere by TypeScript compiler).

Both samples deliver same result in all latest browsers.

For IE11 Promise shim would be needed (sample).

    <script src="https://cdnjs.cloudflare.com/ajax/libs/es6-promise/4.1.1/es6-promise.auto.js"></script>
    <script src="../ts/file1.js" async></script>

My StackOverflow question link

https://stackoverflow.com/questions/48688136/how-to-correctly-implement-async-event-handlers-in-browser

Current state

The current state how every browser handles the async function that is event handler is, that when first await of function returning Promise is evaluated, next event handler is fired, and so on. The very same way as if awaited function would be defered via setTimeout() JS function.

Wanted state

"Wanted state" is expected flow of code where only after whole first event handler is executed, the next event handler kicks in (when no kind of stopPropagation was used).

asynceventdemo's People

Contributors

rostacik avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.