Chaining of Promises via #flatMap() in Play Controller-Action

做~自己de王妃 提交于 2019-12-09 04:35:31

.flatMap is for when some return value of the function you give to it returns a Promise itself. If all you do is return non-futures, then you can just use .map, so the last .flatMap does not seem to need be a .flatMap since you just wrap all the results values in Promise.pure, with .map you can just return those values without further boxing them in a Promise.

The function you give to userPromise.flatMap on the other hand will return a Promise so it must be a flatMap or else it in turn will return Promise<Promise<Result>> which you cannot return from your controller action.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!