Skip to main content

Posts

Showing posts with the label streams

New site for Dart news and articles

For the latest Dart news, visit our new blog at  https://medium.com/dartlang .

An Important New Article on Working with Streams in Dart

Read  Getting Your Feet Wet with Streams ,  the latest article at  dartlang.org  and learn about Streams in Dart . How do you model values that vary over continuous time? Or deal with events which occur at finite points in time? In the Javascript world, the answer often involves using Functional Reactive Programming (FRP), with frameworks like  RxJs, bacon.js and Flapjax providing elegant approaches to traditional event-driven programming.  In Dart,  Streams provide a consistent interface for working with repeating events. Streams are everywhere in Dart!  In an important new article, Chris Buckett details ways in which you can subscribe to (and unsubscribe from) a Stream. He shows how to transform, validate and consume Stream data, and handle errors using a StreamSubscription.  This article demystifies the subject of Streams: read it if you want to know more about this important topic. Your feedback really counts. Please j...

I/O Library Now Uses Streams

We have done a full re-design of the dart:io API (file, network, directories, etc) to use the classes and concepts in the core library and in dart:async. This means that there is almost no callback registration in dart:io any more. All async operations now use streams and futures. (These changes are available in bleeding_edge as of today, and should show up in a weekly build soon.) We think this is a great step forward in aligning all of the “dart:” API's and for you to have fewer concepts to learn when using Dart for different tasks. However this is a breaking change which requires rewriting code using dart:io. The good news is that most of these changes should be mechanical. The following sections describe these changes in more details and give some examples on how to migrate code to the new API. For more information take a look on the API documentation for dart:io. Streams in dart:io The classes InputStream and OutputStream are gone and have been replaced with classes im...

New Streams API with Dart Milestone 3

We are proud to announce the Milestone 3 release of the Dart SDK, which provides a new, cohesive API for asynchronous programming and a unified model for events. Some of the new or improved classes in this release include Iterable, Stream, and Future. Dart's M3 release delivers on a common developer request for a more unified approach to events. New and updated in M3, the Iterable class and the Stream class now provide synchronous and asynchronous models, respectively, for a common theme: a sequence of items. The Iterable class is now much more prominent in Dart and is the ancestor of common collections like List and Set. Many APIs now return Iterable instead of a specific collection. You can map, join, skip, take, and more on an Iterable. Here is an example: var names = getAccounts().where((a) => a.isPlatinum) .map((a) => a.fullName) .toList() ; The Stream class (and its dart:async library) is new, and it provides an asy...

New DOM Event Streams API makes it Easier to Listen to and Capture Events

A new API is on the way for dealing with DOM events in Dart. Google engineer Peter Bois   gives us the details : One of our goals for exposing DOM events in Dart is to have them follow the 'best practices' for events- particularly events which are exposed in places such as your application data model. The current plan is that DOM events would be exposed as: class Element {   static const HtmlStreamProvider<MouseEvent> clickEvent =      const HtmlStreamProvider<MouseEvent> ('click');   Stream<MouseEvent> get onClick => clickEvent.forTarget(this); } The HtmlStreamProvider class is: class HtmlStreamProvider<T extends Event> {   const HtmlStreamProvider(String eventType);   Stream<T> forTarget(EventTarget e, {bool useCapture: false}) } There's basically two parts-  The static declaration of the event as an HtmlStreamProvider which provides a Stream for a DOM event on a speci...