I was going through the link https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Your_second_WebExtension. I could not understand the keyword then() in the choose_beast.js script. I know it is something related to promises in javascript. Can you explain in simple language promises and use of then in this context?
Asynchronous Promise and then()
227 Views Asked by pc.97 At
1
There are 1 best solutions below
Related Questions in FIREFOX
- Firefox 37 throwing error when trying to add microphone volume control for WebRTC audio context
- Polymer 1.0 on Firefox, Safari /deep/ selector not working
- Firefox Windows / Linux inconstancies
- Firefox SDK Add-on - How to start
- PlayN and Firefox issues
- Copy to clipboard from Firefox add-on content script
- SVG data image not working as a background-image in a pseudo element
- Selenium Firefox webdriver does not adopt profile
- how can i use require(""); in javascript
- Skewed border won't display properly in FiFO on MacOs
- Optimize website to show reader view in Firefox
- Remove the black line from the bottom and right side of Firefox select boxes
- Onclick doesn't work in Firefox, but in Chrome - yes
- How do you close the DOM Properties window in Firefox Developer Edition?
- Cannot click on Angular-JS button with selenium web-driver: ElementNotVisibleException
Related Questions in MOZILLA
- how can i use require(""); in javascript
- Polymer paper-dialog on Mozilla Firefox
- Style.css not loading in Mozilla Firefox
- Firefox 38-40 SMIL problems - very slow speed (resolved in FF version 41 from 22.09.15)
- This webpage is not available ERR_NAME_NOT_RESOLVED
- for of loop querySelectorAll
- nss-3.14.1-3.fc16.src.rpm build fails with error: test suite returned failure(s)
- How SCSS rule evaluation done by browser
- css Positions are not same in mozilla and chrome
- Why mozilla changes the characters when i use the .net mvc statement redirect?
- woocommerce thumbnails have different image widths in chrome and mozilla
- php redirection working in chorme but not on firefox
- Geolocation not working in mac - firefox
- Cannot get Java Applets to work in any browser
- Retrieve html code of selected text
Related Questions in FIREFOX-ADDON-WEBEXTENSIONS
- Firefox extension .xpi file structure: description, contents, creation, and installation
- Send data between content-script/background
- How to get url as string from JSON when sending messages in Firefox or Chrome?
- How to get all frameId's in a tab?
- Completely lost on how to save extension popup window content
- tab.openerTabId undefined in Firefox WebExtension
- Can't successfully run executeScript from the background script unless I load the popup page/script first
- Using the same page (and JS) as the background and the popup in FireFox webextension without it reloading
- Newbie, can't find a way for this code to work inside webRequest.onBeforeRequest due return
- webRequest of background requests works in Chrome but not FF
- Get list of chrome extensions allowed in Incognito Mode
- Communicate between scripts in the background context (background script, browser action, page action, options page, etc.)
- Listen in Content Script for when AJAX response changes textarea val
- Firefox WebExtensions: How to open a background page as a unique tab?
- Can WebExtensions be used on Firefox for Android
Related Questions in BROWSER-EXTENSION
- Can browsersync inject updated content in the browser without a refresh?
- Get DOM values in browser extension
- Crossrider extension on browser launch
- Make sure ctypes DLL is called from my extension
- CrossRider - is there a way to pass arrays as function parameters without converting them to objects?
- Is it possible to list running programs/applications from web browser?
- getUserMedia API suport for Opera Local screen share
- CrossRider - How do I inject script to specific tabs? And how do I reload specific tabs?
- Install extension hosted in Chrome Web Store without ugly inline modal
- Getting started writing Extensions/Add-Ons/Plugins/BHOs for IE
- JavaScript completely "tamper safe" variables
- Asynchronous Promise and then()
- How to default Edge extension to show next to address bar by default
- Theoretically possible to bundle Mercurial or Git in a browser extension?
- Multiple JS files in Chrome Extension - how to load them?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Let us compare synchronous and asynchronous code.
Looking at a normal synchronous code:
ais set beforebis set and it is available for the next line to be usedLooking at an asynchronous code:
ais NOT set beforebis set and it is NOT available for the next line to be used, therefore it results in error.The
someAsyncFuntion()is queued to run when the next process is available. The parser moves tolet b = a * 3;but here theais not set yet, so there would be an error.I simple words, in Promise the function is queued to run asynchronously. Therefore,
then()is when it has done it.Looking at the example on above page:
browser.tabs.query()does not run immediately and does not get results immediately. Therefore, we write the code so that when it gets the resultthen()do something.I hope that helps.