Click here to Skip to main content
15,510,771 members
Home / Discussions / JavaScript
   

JavaScript

 
AnswerRe: Javascript: indicate when item in a list clicked? Pin
Member 1469087416-Dec-19 0:21
Member 1469087416-Dec-19 0:21 
Questionre: Highlight all the fields Pin
Member 1466767925-Nov-19 6:27
Member 1466767925-Nov-19 6:27 
AnswerRe: re: Highlight all the fields Pin
jkirkerx25-Nov-19 9:11
professionaljkirkerx25-Nov-19 9:11 
GeneralRe: re: Highlight all the fields Pin
Member 1466767925-Nov-19 12:30
Member 1466767925-Nov-19 12:30 
GeneralRe: re: Highlight all the fields Pin
Member 1466767925-Nov-19 14:02
Member 1466767925-Nov-19 14:02 
QuestionJavaScript Question that doesn't make since. Pin
Member 1466141319-Nov-19 13:07
Member 1466141319-Nov-19 13:07 
AnswerRe: JavaScript Question that doesn't make since. Pin
Afzaal Ahmad Zeeshan19-Nov-19 17:58
mveAfzaal Ahmad Zeeshan19-Nov-19 17:58 
QuestionHow can I avoid the phenomenon of asynchronous code using promises and async/await? Pin
Simos Sigma17-Nov-19 3:38
Simos Sigma17-Nov-19 3:38 
I am working on a cep html panels extension and I am facing this known "thorn" of asynchronous code!!! I know that the most secure way is to use promises and async/await, but my problem is that I can't really understand how I can suit my code to promises and async/await. I believe an example based on my code would really help me.

Here is a small example of my code...

JS FILE CODE:
JavaScript
(function()
{
    'use strict';
	
	const csInterface = new CSInterface();
	const extensionId =  csInterface.getExtensionID();
	let psDocumentsLength;
	
	function init()
	{
		themeManager.init();
	
		$(document).ready(function()
		{
			setTimeout(function(){check_PSDocumentsLength();
				setTimeout(function(){reclaim_PSDocumentsLength();
				}, 100);
			}, 100);
		});
	};
	
	function check_PSDocumentsLength()
	{
		var chosenFunction = 'checkDocumentsLength()';
		csInterface.evalScript(chosenFunction, function(result)
		{
			psDocumentsLength = result;
		});
	};
	
	function reclaim_PSDocumentsLength()
	{
		if(psDocumentsLength < 1)
		{
			alert('There is no opened document!!!');
			csInterface.closeExtension()
		};
	};
    
    init();
	
}());
JSX CODE:
JavaScript
function checkDocumentsLength()
{
	return documents.length;
};

As you can see, in order to avoid the phenomenon of asynchronous code, I am using nested setTimeout(s). Is there anyone who can explain to me how I can do the same thing but using promises and async/await?

Thank you in advance!!!
AnswerRe: How can I avoid the phenomenon of asynchronous code using promises and async/await? Pin
Nathan Minier18-Nov-19 2:35
professionalNathan Minier18-Nov-19 2:35 
AnswerRe: How can I avoid the phenomenon of asynchronous code using promises and async/await? Pin
Richard Deeming18-Nov-19 8:47
mveRichard Deeming18-Nov-19 8:47 
Questionclient's windows login name Pin
kishor kumar S H17-Nov-19 0:47
kishor kumar S H17-Nov-19 0:47 
AnswerRe: client's windows login name Pin
Eddy Vluggen17-Nov-19 1:41
professionalEddy Vluggen17-Nov-19 1:41 
AnswerRe: client's windows login name Pin
Nathan Minier18-Nov-19 2:40
professionalNathan Minier18-Nov-19 2:40 
GeneralRe: client's windows login name Pin
kishor kumar S H18-Nov-19 22:49
kishor kumar S H18-Nov-19 22:49 
GeneralRe: client's windows login name Pin
Nathan Minier19-Nov-19 1:45
professionalNathan Minier19-Nov-19 1:45 
GeneralRe: client's windows login name Pin
kishor kumar S H23-Nov-19 18:54
kishor kumar S H23-Nov-19 18:54 
Question!!Please Help!! Student Needs Help It Shows me exercise 2 is correct but exercise 1 is not defined JS assign 3 and 13 Pin
Member 1465076510-Nov-19 12:20
Member 1465076510-Nov-19 12:20 
AnswerRe: !!Please Help!! Student Needs Help It Shows me exercise 2 is correct but exercise 1 is not defined JS assign 3 and 13 Pin
Richard MacCutchan10-Nov-19 23:23
mveRichard MacCutchan10-Nov-19 23:23 
QuestionGetting this following error: compare.js:1 Uncaught Error: Cannot find module 'ember' Pin
simpledeveloper5-Nov-19 10:26
simpledeveloper5-Nov-19 10:26 
SuggestionRe: Getting this following error: compare.js:1 Uncaught Error: Cannot find module 'ember' Pin
jkirkerx5-Nov-19 12:47
professionaljkirkerx5-Nov-19 12:47 
GeneralRe: Getting this following error: compare.js:1 Uncaught Error: Cannot find module 'ember' Pin
simpledeveloper5-Nov-19 13:14
simpledeveloper5-Nov-19 13:14 
QuestionLoading of a td value using another td value in Ember hbs file Pin
simpledeveloper4-Nov-19 12:32
simpledeveloper4-Nov-19 12:32 
GeneralRe: Loading of a td value using another td value in Ember hbs file Pin
jkirkerx5-Nov-19 13:06
professionaljkirkerx5-Nov-19 13:06 
GeneralRe: Loading of a td value using another td value in Ember hbs file Pin
simpledeveloper5-Nov-19 13:09
simpledeveloper5-Nov-19 13:09 
Questionweb development Pin
Member 142901874-Nov-19 3:14
Member 142901874-Nov-19 3:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.