Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timer should be accessible to web apps running in the browser #1880

Closed
DartBot opened this issue Feb 27, 2012 · 18 comments
Closed

Timer should be accessible to web apps running in the browser #1880

DartBot opened this issue Feb 27, 2012 · 18 comments
Assignees

Comments

@DartBot
Copy link

DartBot commented Feb 27, 2012

This issue was originally filed by @seaneagan


There are currently two mechanisms for setting callbacks to run after a certain duration:

dart:html
  window.setTimeout
  window.setInterval
  window.clearTimeout
  window.clearInterval

dart:io
  Timer interface

This is unnecessary duplication. The dart:html versions should be removed, and the Timer interface should be moved alongside the StopWatch interface in dart:core.

@iposva-google
Copy link
Contributor

I know this was discussed in the past. Matt, Jacob what was the resolution?


cc @jacob314.
Added Area-UI, Triaged labels.

@sigmundch
Copy link
Member

I'll work on making Timer available in corelib, but I'll keep setTimeout around since it is expected to be there. We can decide about that later on.


Set owner to @sigmundch.
Added Accepted label.

@DartBot
Copy link
Author

DartBot commented Mar 12, 2012

This comment was originally written by @seaneagan


Noticed the part about removing window.{set,clear}{Timeout,Interval} duplicates issue #757, so that part could be tracked there.

@sigmundch
Copy link
Member

After we worked on a change to make Timer part of dart:core, we had more discussions about this and (I believe) we agreed to converge the io-related APIs in dart:html and dart:io, rather than moving things to dart:core.

We might require pub or some other mechanisms to support a transparent way of switching between browser and vm-based implementations of the API. The full solution is not clear to me yet.

I'm changing the status back to 'Triaged'...


cc @iposva-google.
cc @madsager.
Removed the owner.
Added Triaged label.

@DartBot
Copy link
Author

DartBot commented Apr 24, 2012

This comment was originally written by @seaneagan


I found the code review for this:

https://chromiumcodereview.appspot.com/9692010/

It's unclear to me why the code was not committed. I saw it was suggested at one point to define the Timer interface in both dart:html and dart:io. That does not help. It would still be impossible to use the interface in code which needs to run transparently in both client and server, and I don't see how pub can help here, and even if it could, I think Timer is clearly a common enough use case that you shouldn't have to resort to any tricks.

If trying to not pollute dart:core's name space, then maybe create a dart:time library which has StropWatch, Clock, Timer, Date, Duration, and TimeZone, which could possibly be auto-imported with no prefix by default just like dart:core.

@munificent
Copy link
Member

It would still be impossible to use the interface in code which needs to run transparently in both client and server, and I don't see how pub can help here

Our plan is that pub will support configuration-specific imports. So your code that needs to transparently use Timer would import something like:

#import('package:timer/timer.dart');

This Timer package can then provide multiple implementations that expose the same interface but internally use dart:io, or dart:html or whatever. When pub looks up that package for your app, it will select an appropriate implementation based on the environment that app runs in.

@DartBot
Copy link
Author

DartBot commented Apr 24, 2012

This comment was originally written by sammcca...@google.com


Finer grained libraries + environment-specific implementations + ability for user-libraries to do the same would be so so awesome.

@sigmundch
Copy link
Member

Exactly - the idea is not that Timer would be defined in both dart:html and dart:io, but that you'd be able to import 'package:timer' (for example) which would have different implementations depending on whether you are targeting the vm or the browser.

@DartBot
Copy link
Author

DartBot commented Apr 24, 2012

This comment was originally written by @seaneagan


I see how pub can help an app which targets only the client OR the server, they can configure their timer package to point to the client or server version as needed. I don't see how it works though if your library/app targets the client AND the server, and uses Timer. I have already run into a similar issue with http requests, see:

http://dartbug.com/2677#c2

@munificent
Copy link
Member

So what I described would work transitively across your dependency graph too. So your library would just import:

#import('package:timer/timer.dart');

which is platform-agnostic. That in turn means your library is platform agnostic. When some app comes along and directly or indirectly uses your app, only then and only in the context of that app will it select an appropriate concrete timer implementation and give it to your app. Concrete package resolution is always in the context of the top-level app and at that point you probably do know what environment(s) it will run on.

@DartBot
Copy link
Author

DartBot commented Apr 25, 2012

This comment was originally written by @seaneagan


Thanks Bob!

Couple questions (for anyone):

Why expose window.{set|clear}{Timeout|Interval}, XmlHttpRequest, and other interfaces which duplicate core libraries such as dart:io at all? Why have two separate ways to do the same thing?

Doesn't it seem strange to have Stopwatch and Clock in dart:core, and Timer elsewhere?

How would packages expose client and server implementations? Presumably either by a package structure convention, or by path configuration in the pub spec file. Also, it seems there would be a need for "interface libraries" (and maybe even interface packages?) on which to base the client and server implementations, and for use by analysis engines.

Then "pub serve" and "pub deploy" and "dart2js" (called by pub) could use the convention or configuration to find the client implementations of packages. A Dart VM running on the server could similarly find server implementations of packages.

@whesse
Copy link
Contributor

whesse commented May 1, 2012

Issue #2851 has been merged into this issue.

@sethladd
Copy link
Contributor

Any status on this? In this case, the Timer interface could be used in both server and client environments, enhancing the story of "writing Dart code that works in two places".

@DartBot
Copy link
Author

DartBot commented Jun 6, 2012

This comment was originally written by TerryMitsuok...@gmail.com


Why does it take so long time? Since I asked for that ASAP in April (https://groups.google.com/a/dartlang.org/group/misc/browse_thread/thread/6a396cf6305341c3#), my precision timer isolate application (https://gist.github.com/2652622) still needs external tick messages.

@sethladd
Copy link
Contributor

Timer was moved into dart:isolate so I think we can close this issue. Please correct me if I'm wrong.


Added Fixed label.
Changed the title to: "Timer should be accessible to web apps running in the browser".

@sigmundch
Copy link
Member

Unfortunately is not complete.

The interface moved to dart:isolate, but only the VM has the implementation available. We have to make the implementation for dart2js available too.


Set owner to @sigmundch.
Added Started label.

@sethladd
Copy link
Contributor

Issue #4013 has been merged into this issue.


cc @rakudrama.
cc @vsmenon.

@sigmundch
Copy link
Member

Fixed in r10460


Added Fixed label.

copybara-service bot pushed a commit that referenced this issue Jan 10, 2023
…_server, http_parser, logging, mockito, path, pool, shelf, source_map_stack_trace, sse, stream_channel, term_glyph, test, typed_data, watcher, web_socket_channel, webdev, webkit_inspection_protocol, yaml

Revisions updated by `dart tools/rev_sdk_deps.dart`.

cli_util (https://github.com/dart-lang/cli_util/compare/5a8e8ee..32bc077):
  32bc077  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#73)

clock (https://github.com/dart-lang/clock/compare/6b8b7bf..65e8a13):
  65e8a13  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#42)

csslib (https://github.com/dart-lang/csslib/compare/d776535..7054945):
  7054945  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#157)

dartdoc (https://github.com/dart-lang/dartdoc/compare/29a1bbf..c4ab682):
  c4ab6824  2023-01-10  Sam Rawlins  Regenerate so latest analyzer is happy (#3293)

fixnum (https://github.com/dart-lang/fixnum/compare/714381c..71f0d4d):
  71f0d4d  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#103)

glob (https://github.com/dart-lang/glob/compare/7adf833..4579281):
  4579281  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#68)

http_multi_server (https://github.com/dart-lang/http_multi_server/compare/beb40a7..cce5080):
  cce5080  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#48)

http_parser (https://github.com/dart-lang/http_parser/compare/16a4f34..6f73e4a):
  6f73e4a  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#66)

logging (https://github.com/dart-lang/logging/compare/b525d5c..34ed68f):
  34ed68f  2023-01-09  Kevin Moore  Move to new analyzer language settings (#126)

mockito (https://github.com/dart-lang/mockito/compare/942dd03..9cc958a):
  9cc958a  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts

path (https://github.com/dart-lang/path/compare/1299791..9768908):
  9768908  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#133)

pool (https://github.com/dart-lang/pool/compare/713e631..ad4e2a7):
  ad4e2a7  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#60)

shelf (https://github.com/dart-lang/shelf/compare/32e342d..a44e95e):
  a44e95e  2023-01-10  Kevin Moore  Fix doc comment references (#323)

source_map_stack_trace (https://github.com/dart-lang/source_map_stack_trace/compare/e5f9564..adea3e5):
  adea3e5  2023-01-09  Sam Rawlins  Migrate no-implicit-casts to strict-casts (#32)

sse (https://github.com/dart-lang/sse/compare/3c37edb..be426a2):
  be426a2  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#74)

stream_channel (https://github.com/dart-lang/stream_channel/compare/0a7800a..3b99268):
  3b99268  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#84)

term_glyph (https://github.com/dart-lang/term_glyph/compare/2bf4594..8cd9318):
  8cd9318  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#31)

test (https://github.com/dart-lang/test/compare/3415089..932a652):
  932a652b  2023-01-09  Nate Bosch  Add a Map operator[] extension (#1830)
  1f2e963e  2023-01-09  Nate Bosch  Add Future.doesNotComplete condition (#1827)

typed_data (https://github.com/dart-lang/typed_data/compare/dbf81a7..9c209b9):
  9c209b9  2023-01-09  Sam Rawlins  Migrate no-implicit-casts to strict-casts (#58)

watcher (https://github.com/dart-lang/watcher/compare/2e0db71..3b49c7e):
  3b49c7e  2023-01-09  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#134)

web_socket_channel (https://github.com/dart-lang/web_socket_channel/compare/ebd0fe9..28d7b82):
  28d7b82  2023-01-10  Kevin Moore  Fix CI link in readme (#248)
  c6ce895  2023-01-09  Sam Rawlins  Update analysis_options.yaml (#247)

webdev (https://github.com/dart-lang/webdev/compare/49f97b8..094ee97):
  094ee97  2023-01-10  Anna Gringauze  Add back setExceptionPauseMode (#1871)
  2e65ddf  2023-01-10  Anna Gringauze  Prepare for dart 3.0 alpha breaking changes (#1880)
  2e2587a  2023-01-10  Elliott Brooks (she/her)  Add hotfix instructions to DWDS (#1876)
  fe39123  2023-01-10  Elliott Brooks (she/her)  Re-enable `reload_tests` (#1877)
  e71c0e3  2023-01-09  Anna Gringauze  Fix crash on processing devtools event (#1875)

webkit_inspection_protocol (https://github.com/google/webkit_inspection_protocol.dart/compare/ddb624c..15244ff):
  15244ff  2023-01-09  Kevin Moore  Add cron to CI (#97)

yaml (https://github.com/dart-lang/yaml/compare/02be51e..b2fce6c):
  b2fce6c  2023-01-10  Sam Rawlins  Migrate from no-implicit-casts to strict-casts (#134)

Change-Id: I4fb257fe7c697fab562f4d18e4ea50c5903b4cd8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278807
Auto-Submit: Devon Carew <devoncarew@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants