Giter VIP home page Giter VIP logo

Comments (10)

lihaoyi avatar lihaoyi commented on August 16, 2024

Why should they take an ExecutionContext? They're just making a synchronous
call right-now, the future that you get back takes execution contexts for
everything it does =P

On Mon, Nov 10, 2014 at 4:51 PM, Boris Shabalin [email protected]
wrote:

Noticed that that methods for working with ajax in scala-js-dom extensions
https://github.com/scala-js/scala-js-dom/blob/master/src/main/scala/org/scalajs/dom/extensions/Extensions.scala#L162
don't respect any ExecutionContext. Is there any particular reason for
that? Or should I make a PR?


Reply to this email directly or view it on GitHub
#62.

from scala-js-dom.

MrAIring avatar MrAIring commented on August 16, 2024

According to the documentation: "...They [execution contexts] are essential for the future method because they handle how and when the asynchronous computation is executed." So, future that I getting back will use execution context for methods like flatMap but not for making actual ajax call.

from scala-js-dom.

lihaoyi avatar lihaoyi commented on August 16, 2024

How do you change the threadpool an XMLHttpRequest executes on?

On Mon, Nov 10, 2014 at 5:00 PM, Boris Shabalin [email protected]
wrote:

According to documentation
http://docs.scala-lang.org/overviews/core/futures.html "Execution
contexts execute tasks submitted to them, and you can think of execution
contexts as thread pools. They are essential for the future method because
they handle how and when the asynchronous computation is executed." So,
future that I getting back will use execution context for methods like
flatMap but not for making actual ajax call.


Reply to this email directly or view it on GitHub
#62 (comment)
.

from scala-js-dom.

MrAIring avatar MrAIring commented on August 16, 2024

There is no threadpools in js environment but we have at least two different execution contexts in scala.js. Even if I import scala.scalajs.concurrent.JSExecutionContext.Implicits.runNow my ajax calls will remain asynchronious.

from scala-js-dom.

lihaoyi avatar lihaoyi commented on August 16, 2024

So what is it you are really proposing =P

On Mon, Nov 10, 2014 at 5:40 PM, Boris Shabalin [email protected]
wrote:

There is no threadpools in js environment but we have at least two
different execution contexts in scala.js. Even if I import
scala.scalajs.concurrent.JSExecutionContext.Implicits.runNow my ajax
calls will remain asynchronious.


Reply to this email directly or view it on GitHub
#62 (comment)
.

from scala-js-dom.

MrAIring avatar MrAIring commented on August 16, 2024

Well, this one

from scala-js-dom.

lihaoyi avatar lihaoyi commented on August 16, 2024

I've taken a look at it, I don't see it actually doing anything =/ from a user point of view, how is this different from the status quo?

from scala-js-dom.

MrAIring avatar MrAIring commented on August 16, 2024

With proposed change user can control how ajax calls executed by means of custom ExecutionContext. For example, I may want all of my calls to be synchronous with JSExecutionContext.runNow, or I want to make sure that there is no more than n simultaneous requests to server and make my own execution context for that purpose.

from scala-js-dom.

lihaoyi avatar lihaoyi commented on August 16, 2024

I don't see why the library needs to know about this. If you really wished to wrap your calls in a Future, you can already do so. and flatten the results out. The contents of the Ajax function does not use any Future methods, and thus doesn't need an execution context. Just because you can do it inside the function doesn't mean you should. In fact, if you can just-as-easily do it outside the function, that's a good sign it shouldn't be stuffed inside.

from scala-js-dom.

MrAIring avatar MrAIring commented on August 16, 2024

I get your point, thanks.

from scala-js-dom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.