I need to get the user input to continue excecution of a functoion , how can i make the function wait for waitForUserInput().
if i can solve this using observables can anyone help me to integrate observables to a simple functiuon defined inside components
this is where iam stuck
myFunction(){
doSomeOperation();
result=waitForUserInput(); // Here a prompt will be shown,
if(result==1)
{
operation1();
}
else if(result==2)
{
operation2();
}
else if(result==3)
{
operation3();
}
}
// This function will show a prompt and user can input values
waitForUserInput(){
showUserInputPrompt();
if(input==someValue1)
{
return 1;
}
else if(input==someValue2)
{
return 2;
}
else if(input==someValue3)
{
return 3;
}
}
here i need to wait until waitForUserInput() is completed before proceeding
That's not possible. You can't halt a function in the browser. In the browser there is only one UI thread. If you halt it, nothing will happen anymore in your application, therefore it's not supported at all.
You need to choose a different strategy to get what you want to accomplish.
If your called function allows for callback you can do something like this=>
this.instance.saveEditData().done(this.CustomSave);
function CustomSave() { }
CustomSave is the parent and I was calling saveEditData inside it. But changed the logic to call it only when saveEditData is done.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.