I have a timer set for one minute and an asynchronous task already initiated (which will return a true or false). On timer expire,
if the asynchronous task has returned and if it is true I want to show 'Success'.
If the asynchronous task has returned and the value is false, I want to display 'Failure'.
If asynchronous task is not returned yet,I want to wait for the response and show 'Success' and 'Failure' according to the async tasks value.
Imperative Programming (Pseudo code):
//Use a global variable
var asyncValue = null/nil //To hold the value of async tasks output.
//Asynchronous call back.
onAsyncReturned(bool value){
ayncValue = value
}
//So finally, on timer expire.
switch(asyncValue){
case null/nil : //Asynchronous task not returned yet.
case true : //Show 'Success' message.
case false : //Show 'Failure' message.
}
Functional Programming: ?????