Comments (10)
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.
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.
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.
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.
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.
Well, this one
from scala-js-dom.
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.
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.
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.
I get your point, thanks.
from scala-js-dom.
Related Issues (20)
- `Location` should be a `class`
- `Location#origin` should return a `String` HOT 1
- Fetch `RequestInit` needs duplex attribute HOT 1
- Add `PageTransitionEvent` HOT 1
- Typo in "WriteableStream" trait name? HOT 1
- Recommended approach when `Response.type` is undefined? HOT 1
- `Element#id` returns undefined HOT 2
- Update available MIMEtypes HOT 5
- Use `XMLDocument` type when parsing XML string in `DOMParser` HOT 3
- Remove attributes class members from Node
- is changing `Array` -> `FrozenArray` binary compatible? HOT 4
- It looks we are missing some methods from the FormData class HOT 2
- Confusing type of ImageData.data HOT 3
- Create bindings for webgpu
- WebAudio classes
- LockOptions doesn't use val for fields, making overriding not possible HOT 2
- Constructor parameters for URLSearchParams are not quite right
- Clarify `enum` and `object literals` usage in `scalajs-dom`
- Return Type of HTMLCanvasElement getContext is not clear. HOT 1
- Support Int.Locale
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scala-js-dom.