Explaning is Future Working In Play controllerClarification needed about futures and promises in ScalaAre Play framework controller actions synchronized?Wait for any of given Futures in Scala?Scala 2 futures containing api calls race conditionPlay 2.2 java - can one controller call another?Are there any benefits in using non-async actions in Play Framework 2.2?Convert Play Framework java Promise to Play Framework Scala PromiseUsing Future inside a View in play 2.3.2Call 2 Futures in the same Action.async Scala Playscala: mapping future of tupleBest practices to use Future inside a Controller (Play+Scala)

Why is a dedicated QA team member necessary?

Is there a way to shorten this while condition?

USA: Can a witness take the 5th to avoid perjury?

Why do people say "I am broke" instead of "I am broken"?

How can I receive packages while in France?

What was the rationale behind 36 bit computer architectures?

How can I prevent corporations from growing their own workforce?

Are gangsters hired to attack people at a train station classified as a terrorist attack?

Sextortion with actual password not found in leaks

What are the exact meanings of roll, pitch and yaw?

The seven story archetypes. Are they truly all of them?

Why no ";" after "do" in sh loops?

Why are off grid solar setups only 12, 24, 48 VDC?

Spoken encryption

Monty Hall Problem with a Fallible Monty

Is two-person D&D feasible for any edition?

What is a reasonable time for modern human society to adapt to dungeons?

Extrapolation v. Interpolation

Other than a swing wing, what types of variable geometry have flown?

Is it normal practice to screen share with a client?

If my business card says 〇〇さん, does that mean I'm referring to myself with an honourific?

Does static fire reduce reliability?

Why did NASA use U.S customary units?

Strange Cron Job takes up 100% of CPU Ubuntu 18 LTS Server



Explaning is Future Working In Play controller


Clarification needed about futures and promises in ScalaAre Play framework controller actions synchronized?Wait for any of given Futures in Scala?Scala 2 futures containing api calls race conditionPlay 2.2 java - can one controller call another?Are there any benefits in using non-async actions in Play Framework 2.2?Convert Play Framework java Promise to Play Framework Scala PromiseUsing Future inside a View in play 2.3.2Call 2 Futures in the same Action.async Scala Playscala: mapping future of tupleBest practices to use Future inside a Controller (Play+Scala)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am needing explaining on how future is working in my play controller.



I have some code in my service layer which is calling a Java library API. When I first call my Java API like this in a controller:



def someController() = Action 
someJavaAPI()
Ok("done")



For this controller, I did not see any action. I expect action because of a call to someJavaAPI. Then somebody told me that someJavaAPI is dying because the controller is finishing too early. Is that right?



So I changed the code to be like this: I am wrapping someJavaAPI() method in a Future



def someJavaAPI() = Future ....code....


Now I calling this like this in my contraoller:



def someController() = Action 
someJavaAPI().map _ => Ok("done")



This is working very good.



My question is: is wrapping someJavaAPI in future makes controller thread wait until it finished and then does map function?



Also, what is Promise? Can I use Promise here? I am not sure.










share|improve this question
























  • Please refer docs.scala-lang.org/overviews/core/futures.html and stackoverflow.com/questions/18960339/…. It will answer most of your questions

    – Chaitanya Waikar
    Mar 26 at 16:15






  • 1





    How exactly did you call java API in both cases?

    – Andriy Kuba
    Mar 26 at 21:09











  • @AndriyKuba I am not sure what you are meaning. Java library method is called like I show,

    – Mojo
    Mar 27 at 9:09

















0















I am needing explaining on how future is working in my play controller.



I have some code in my service layer which is calling a Java library API. When I first call my Java API like this in a controller:



def someController() = Action 
someJavaAPI()
Ok("done")



For this controller, I did not see any action. I expect action because of a call to someJavaAPI. Then somebody told me that someJavaAPI is dying because the controller is finishing too early. Is that right?



So I changed the code to be like this: I am wrapping someJavaAPI() method in a Future



def someJavaAPI() = Future ....code....


Now I calling this like this in my contraoller:



def someController() = Action 
someJavaAPI().map _ => Ok("done")



This is working very good.



My question is: is wrapping someJavaAPI in future makes controller thread wait until it finished and then does map function?



Also, what is Promise? Can I use Promise here? I am not sure.










share|improve this question
























  • Please refer docs.scala-lang.org/overviews/core/futures.html and stackoverflow.com/questions/18960339/…. It will answer most of your questions

    – Chaitanya Waikar
    Mar 26 at 16:15






  • 1





    How exactly did you call java API in both cases?

    – Andriy Kuba
    Mar 26 at 21:09











  • @AndriyKuba I am not sure what you are meaning. Java library method is called like I show,

    – Mojo
    Mar 27 at 9:09













0












0








0








I am needing explaining on how future is working in my play controller.



I have some code in my service layer which is calling a Java library API. When I first call my Java API like this in a controller:



def someController() = Action 
someJavaAPI()
Ok("done")



For this controller, I did not see any action. I expect action because of a call to someJavaAPI. Then somebody told me that someJavaAPI is dying because the controller is finishing too early. Is that right?



So I changed the code to be like this: I am wrapping someJavaAPI() method in a Future



def someJavaAPI() = Future ....code....


Now I calling this like this in my contraoller:



def someController() = Action 
someJavaAPI().map _ => Ok("done")



This is working very good.



My question is: is wrapping someJavaAPI in future makes controller thread wait until it finished and then does map function?



Also, what is Promise? Can I use Promise here? I am not sure.










share|improve this question
















I am needing explaining on how future is working in my play controller.



I have some code in my service layer which is calling a Java library API. When I first call my Java API like this in a controller:



def someController() = Action 
someJavaAPI()
Ok("done")



For this controller, I did not see any action. I expect action because of a call to someJavaAPI. Then somebody told me that someJavaAPI is dying because the controller is finishing too early. Is that right?



So I changed the code to be like this: I am wrapping someJavaAPI() method in a Future



def someJavaAPI() = Future ....code....


Now I calling this like this in my contraoller:



def someController() = Action 
someJavaAPI().map _ => Ok("done")



This is working very good.



My question is: is wrapping someJavaAPI in future makes controller thread wait until it finished and then does map function?



Also, what is Promise? Can I use Promise here? I am not sure.







scala playframework






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 16:42









Krzysztof Atłasik

10.5k2 gold badges21 silver badges46 bronze badges




10.5k2 gold badges21 silver badges46 bronze badges










asked Mar 26 at 16:11









MojoMojo

1368 bronze badges




1368 bronze badges












  • Please refer docs.scala-lang.org/overviews/core/futures.html and stackoverflow.com/questions/18960339/…. It will answer most of your questions

    – Chaitanya Waikar
    Mar 26 at 16:15






  • 1





    How exactly did you call java API in both cases?

    – Andriy Kuba
    Mar 26 at 21:09











  • @AndriyKuba I am not sure what you are meaning. Java library method is called like I show,

    – Mojo
    Mar 27 at 9:09

















  • Please refer docs.scala-lang.org/overviews/core/futures.html and stackoverflow.com/questions/18960339/…. It will answer most of your questions

    – Chaitanya Waikar
    Mar 26 at 16:15






  • 1





    How exactly did you call java API in both cases?

    – Andriy Kuba
    Mar 26 at 21:09











  • @AndriyKuba I am not sure what you are meaning. Java library method is called like I show,

    – Mojo
    Mar 27 at 9:09
















Please refer docs.scala-lang.org/overviews/core/futures.html and stackoverflow.com/questions/18960339/…. It will answer most of your questions

– Chaitanya Waikar
Mar 26 at 16:15





Please refer docs.scala-lang.org/overviews/core/futures.html and stackoverflow.com/questions/18960339/…. It will answer most of your questions

– Chaitanya Waikar
Mar 26 at 16:15




1




1





How exactly did you call java API in both cases?

– Andriy Kuba
Mar 26 at 21:09





How exactly did you call java API in both cases?

– Andriy Kuba
Mar 26 at 21:09













@AndriyKuba I am not sure what you are meaning. Java library method is called like I show,

– Mojo
Mar 27 at 9:09





@AndriyKuba I am not sure what you are meaning. Java library method is called like I show,

– Mojo
Mar 27 at 9:09












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55361639%2fexplaning-is-future-working-in-play-controller%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55361639%2fexplaning-is-future-working-in-play-controller%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript