I am trying to make an application that is capable of running on both the client and server. I need to make http requests in this application. Is it possible to conditionally import dart:io or dart:html to make this work?
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
I think one solution to this problem has been to make two top level projects, one for dart:io and one for dart:html, and for them to both import a library that contains most of the shared code for your project.
Many people have been trying to solve this issue, so it would be good to hear from some of them about the solutions they have found. Is there a better way?
--
We did consider making dart:io and dart:html always available, but "broken" where they don't make sense. This seems like such a simple solution to me, and I don't understand why it didn't get any traction.
The point where "dart:html" doesn't make sense without a browser is "everywhere'.
On Sat, Mar 1, 2014 at 9:57 AM, Peter Ahé <a...@google.com> wrote:
We did consider making dart:io and dart:html always available, but "broken" where they don't make sense. This seems like such a simple solution to me, and I don't understand why it didn't get any traction.The point where "dart:html" doesn't make sense without a browser is "everywhere'.The library is a wrapper around a DOM document, which you don't have in the server-side VM.You will have neither "document" nor "window".
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
On Mar 1, 2014 10:35 AM, "Gen" <gp78...@gmail.com> wrote:
>
> Good idea for a bad situation.
>
> It would be great if HTML or Dart VM would offer direct file access to a certain (restricted) part of the local filesystem; like a webserver server side.
> I do not understand why that idea did not get any traction either.
> That feature would make Dart clearly superior to Javascript; at least for a short time.
>
> And it would be great to have the "html" package functional if there is a browser installed on the system.
>
> By "broken" you mean "null" or throwing exceptions ?
>
Yes. I favor throwing exceptions.
Cheers,
Peter
On Mar 1, 2014 11:39 AM, "Lasse R.H. Nielsen" <l...@google.com> wrote:
>
>
>
>
> On Sat, Mar 1, 2014 at 9:57 AM, Peter Ahé <a...@google.com> wrote:
>>
>> We did consider making dart:io and dart:html always available, but "broken" where they don't make sense. This seems like such a simple solution to me, and I don't understand why it didn't get any traction.
>
>
> The point where "dart:html" doesn't make sense without a browser is "everywhere'.
That's not true, and besides the point.
It's besides the point because this solution isn't to share functionality between dart:io and dart:html. This is solely to provide a simple alternative to conditional imports.
It's not true because of things like HttpRequest and a ton of other API that is completely independent of HTML.
> The library is a wrapper around a DOM document, which you don't have in the server-side VM.
> You will have neither "document" nor "window".
>
That's not how dart:html works. There's a bunch of classes in that library that are useful without a HTML document or a browser window. Most of these classes correspond to the worker API. See https://developer.mozilla.org/en-US/docs/Web/Guide/Performance/Using_web_workers
Cheers,
Peter
> /L
> --
> Lasse R.H. Nielsen - l...@google.com
> 'Faith without judgement merely degrades the spirit divine'
> Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K - Denmark - CVR nr. 28 86 69 84
>
I agree 100%, having an HTML parser masquerading as the DOM API would be awesome.
Should it be bundled with the standalone VM? Should it be a package? The easy answer is a package, but bundled with the VM even the constructors would work.
Cheers,
Peter
This way at least it is possible to use the native browser random number generator (or any other one)and even while I like that use-case in general and probably will add it (it is useful!) I really would like to use window.crypto.getRandomValuesas default if it is available and don't want to put the burden on the user to know about the possibility.Any ideas/tips on this? :)