-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Unified event handling model #1873
Comments
cc @sigmundch. |
Added Isolates label. |
Comments from a recent Code Lab: "Contrast: WebSocketConnection "ws.onClosed=(int, String){}" syntax is very different from the WebSocket "ws.on.close.add((e){})" syntax. That's weird and surprising." |
The events in dart:io should also be unified in this way. It would be good if whatever event model we ended up using supported multiple listeners per event. See also issue #4202. |
This comment was originally written by [email protected] I just had a need for firing events in my classes to let other code know about "events". I also ended up writing an ObservableList class that utilizes my event library, but I'd really like to see native support for events Dart so that any class can just fire an event, etc. This could be implemented on a very base class or be a mixin called Observable that you just mix into whatever classes you want to. |
This comment was originally written by [email protected] http://ricardo.cc/2012/08/09/Its-time-for-a-native-EventEmitter.html Explains nicely in what kind of mess you can end up with if you don't provide native language event support, or a canonical complete implementation in the base library. |
Added Library-Isolates label. |
Removed Isolates label. |
Changed the title to: "Unified event handling model". |
This comment was originally written by [email protected] Since events, messages, async operations, network I/O, iterators, etc. can all be considered either terminating or non-terminating sequences of data, I propose that they all be unified under the same Observable model. Examples: Observable Observable // composability // combinators Benefits:
See http://pub.dartlang.org/packages/reactive as a reference project. |
Added Library-Isolate label. |
Removed Library-Isolates label. |
This comment was originally written by [email protected] I agree with this change request. I want my class to be able to alert other classes that some state has changed. |
This comment was originally written by [email protected] The new Stream API in Dart is going to be their unified eventing pattern. It still has some rough edges, but it is completely composable and gives all the desired features listed in this issue. I just created a package that makes exposing custom events as streams really easy. I am guessing that the Dart team will have similar functionality built into the SDK soon. Here is my pub package: http://pub.dartlang.org/packages/event_stream Here is an example of how to create a custom event: class ClassWithEvents implements NotifyPropertyChanged { final EventStream<PropertyChangedEventArgs> _onPropertyChangedEvent = new EventStream<PropertyChangedEventArgs>(); final EventStream _onClosedEvent = new EventStream(); String get someProperty => _someProperty; close() { main() { |
This comment was originally written by [email protected] Just checked out the event_stream package. It definitely helps simplify things. |
Hi Florian, I think we can close this, yes? cc @floitschG. |
Yes. Added Fixed label. |
…g, mockito, package_config, shelf, string_scanner, test, webdev Revisions updated by `dart tools/rev_sdk_deps.dart`. async (https://github.com/dart-lang/async/compare/f700e9a..f700e9a): f700e9a 2023-01-27 Devon Carew blast_repo fixes (#231) characters (https://github.com/dart-lang/characters/compare/4526aa8..4526aa8): 4526aa8 2023-01-30 Lasse R.H. Nielsen Update tables to Unicode 15.0. (#71) collection (https://github.com/dart-lang/collection/compare/a566328..a566328): a566328 2023-01-26 Devon Carew add a publish script; prep to publish (#267) dartdoc (https://github.com/dart-lang/dartdoc/compare/bc7bdc4..bc7bdc4): bc7bdc44 2023-01-30 dependabot[bot] Bump js from 0.6.5 to 0.6.7 (#3310) json_rpc_2 (https://github.com/dart-lang/json_rpc_2/compare/e73c4ad..e73c4ad): e73c4ad 2023-01-26 Devon Carew blast_repo fixes (#89) logging (https://github.com/dart-lang/logging/compare/399100a..399100a): 399100a 2023-01-26 Devon Carew add a publish script; prep to publish 1.1.1 (#128) mockito (https://github.com/dart-lang/mockito/compare/d2a8df1..d2a8df1): d2a8df1 2023-01-30 Kevin Moore Latest build_web_compilers, move to pkg:lints, fix breaks (#605) 13340b5 2023-01-30 dependabot[bot] Bump dart-lang/setup-dart from 1.3 to 1.4 (#600) package_config (https://github.com/dart-lang/package_config/compare/3fe81c4..3fe81c4): 3fe81c4 2023-01-30 Kevin Moore Support latest pkg:build_web_compilers, lints. Update min SDK (#129) shelf (https://github.com/dart-lang/shelf/compare/8fca9d9..8fca9d9): 8fca9d9 2023-01-26 Devon Carew blast_repo fixes (#326) string_scanner (https://github.com/dart-lang/string_scanner/compare/29e471e..29e471e): 29e471e 2023-01-30 dependabot[bot] Bump dart-lang/setup-dart from 1.3 to 1.4 (#53) test (https://github.com/dart-lang/test/compare/cec47c1..cec47c1): cec47c1c 2023-01-27 Nate Bosch Add missing pub requirements (#1878) c99d455e 2023-01-27 Nate Bosch Prepare to publish (#1877) 0e7ec6a7 2023-01-27 Nate Bosch Rename `Check` to `Subject` (#1875) 78382731 2023-01-27 Nate Bosch Add String.matches condition (#1874) 26e0e87b 2023-01-27 Nate Bosch Add Iterable.containsInOrder condition (#1873) c9232d6b 2023-01-27 Nate Bosch Rename `that` to `which` (#1872) 457166b3 2023-01-26 Nate Bosch Add missing dependency on package:lints (#1876) 193f2a0b 2023-01-26 Nate Bosch Retry instead of extend timeout for flaky Node tests (#1871) 7ad9b2c3 2023-01-26 Nate Bosch Overhaul async matchers (#1868) ca254546 2023-01-26 Nate Bosch Add a withQueue utility (#1870) 6ae2e5e9 2023-01-26 Nate Bosch Refactor tests to a new isRejectedBy utility (#1867) 5aeba66d 2023-01-26 Nate Bosch Use pubspec_overrides.yaml files (#1869) webdev (https://github.com/dart-lang/webdev/compare/ce9c581..ce9c581): ce9c581 2023-01-29 Anna Gringauze Validate only needed summaries in expression_compiler_service (#1920) Change-Id: I3ddb0ddeb3b989f6f9e78cd8aa6327aba5899018 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280078 Commit-Queue: Devon Carew <[email protected]> Auto-Submit: Devon Carew <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
This issue was originally filed by @seaneagan
Dart needs a unified approach to handling asynchronous events including:
ui events (dart:html)
async operation completion (Future/Completer in dart:core)
Message sending and receiving (dart:isolates)
Strawman proposal at:
https://docs.google.com/document/d/17crOxOmR5AYwultXbNcfdbvD4ACBw5a9QbvO90FVgtk/edit
The text was updated successfully, but these errors were encountered: