Click here to Skip to main content
15,907,326 members
Home / Discussions / JavaScript
   

JavaScript

 
AnswerRe: Javascript: indicate when item in a list clicked? Pin
Member 1469087415-Dec-19 23:21
Member 1469087415-Dec-19 23:21 
Questionre: Highlight all the fields Pin
Member 1466767925-Nov-19 5:27
Member 1466767925-Nov-19 5:27 
AnswerRe: re: Highlight all the fields Pin
jkirkerx25-Nov-19 8:11
professionaljkirkerx25-Nov-19 8:11 
GeneralRe: re: Highlight all the fields Pin
Member 1466767925-Nov-19 11:30
Member 1466767925-Nov-19 11:30 
GeneralRe: re: Highlight all the fields Pin
Member 1466767925-Nov-19 13:02
Member 1466767925-Nov-19 13:02 
QuestionJavaScript Question that doesn't make since. Pin
Member 1466141319-Nov-19 12:07
Member 1466141319-Nov-19 12:07 
AnswerRe: JavaScript Question that doesn't make since. Pin
Afzaal Ahmad Zeeshan19-Nov-19 16:58
professionalAfzaal Ahmad Zeeshan19-Nov-19 16:58 
QuestionHow can I avoid the phenomenon of asynchronous code using promises and async/await? Pin
Simos Sigma17-Nov-19 2:38
Simos Sigma17-Nov-19 2: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 1:35
professionalNathan Minier18-Nov-19 1:35 
AnswerRe: How can I avoid the phenomenon of asynchronous code using promises and async/await? Pin
Richard Deeming18-Nov-19 7:47
mveRichard Deeming18-Nov-19 7:47 
Questionclient's windows login name Pin
kishor kumar S H16-Nov-19 23:47
kishor kumar S H16-Nov-19 23:47 
AnswerRe: client's windows login name Pin
Eddy Vluggen17-Nov-19 0:41
professionalEddy Vluggen17-Nov-19 0:41 
AnswerRe: client's windows login name Pin
Nathan Minier18-Nov-19 1:40
professionalNathan Minier18-Nov-19 1:40 
GeneralRe: client's windows login name Pin
kishor kumar S H18-Nov-19 21:49
kishor kumar S H18-Nov-19 21:49 
GeneralRe: client's windows login name Pin
Nathan Minier19-Nov-19 0:45
professionalNathan Minier19-Nov-19 0:45 
GeneralRe: client's windows login name Pin
kishor kumar S H23-Nov-19 17:54
kishor kumar S H23-Nov-19 17: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 11:20
Member 1465076510-Nov-19 11: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 22:23
mveRichard MacCutchan10-Nov-19 22:23 
QuestionGetting this following error: compare.js:1 Uncaught Error: Cannot find module 'ember' Pin
simpledeveloper5-Nov-19 9:26
simpledeveloper5-Nov-19 9:26 
SuggestionRe: Getting this following error: compare.js:1 Uncaught Error: Cannot find module 'ember' Pin
jkirkerx5-Nov-19 11:47
professionaljkirkerx5-Nov-19 11:47 
GeneralRe: Getting this following error: compare.js:1 Uncaught Error: Cannot find module 'ember' Pin
simpledeveloper5-Nov-19 12:14
simpledeveloper5-Nov-19 12:14 
QuestionLoading of a td value using another td value in Ember hbs file Pin
simpledeveloper4-Nov-19 11:32
simpledeveloper4-Nov-19 11:32 
GeneralRe: Loading of a td value using another td value in Ember hbs file Pin
jkirkerx5-Nov-19 12:06
professionaljkirkerx5-Nov-19 12:06 
GeneralRe: Loading of a td value using another td value in Ember hbs file Pin
simpledeveloper5-Nov-19 12:09
simpledeveloper5-Nov-19 12:09 
Questionweb development Pin
Member 142901874-Nov-19 2:14
Member 142901874-Nov-19 2: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.