Posts

Showing posts from February, 2013

Exploring Dart's Async Library

Image
(Warning: work in progress...)

Use Dart's async library to keep work off the main UI thread and help your users have a smooth and performant experience. The dart:async library contains classes for timers, futures, streams, and more. Effective use of dart:async keeps your apps easier to understand and your UI snappy.

The event loop
Or, why this all matters.

Dart programs, just like JavaScript, have no shared-state threads. The UI and the program use the same thread of execution, so when the UI is updating the program isn't running. Conversely, when the programming is running, the UI isn't updating. Keeping work off of the main thread means more time for the UI to respond to user input, which means the UI feels snappy and responsive.

The runtime maintains an event loop and a queue of work to perform. The event loops pops work items off of the queue, one after another. While one work item is handled, the other work items sit in the queue patiently.

Examples of work items can i…

Lawndart helps you write offline web apps

Image
I'm happy to announce my new Lawndart library for Dart, which helps you build offline-enabled modern web apps. Using Lawndart, you can use a consistent and easy interface no matter what underlying storage mechanism is supported.


Lawndart was initially inspired by lawnchair, a JavaScript library that helps to provide a consistent interface across client-side storage. However, Lawndart evolved and adopted a Future based API for more composable methods.

Available in version 0.2.0:
Unified API for in-memory, local storage, indexed db, and websqlFuture-based APIsTestsExample Web UI app with IndexedDB
Here is an example of using Lawndart to open, clear, save, and retrieve data:

var store = new IndexedDbAdapter('teststore', 'testdb'); store.open() .then((_) => store.nuke()) .then((_) => store.save(id, "hello")) .then((_) => store.save("is fun", "dart")) .then((_) => store.getByKey("hello")) .then((v…

Slides from JFokus talk on Dart and Web Components

Image
I had the pleasure of presenting "Web Components Now: Dart and Web UI" at JFokus 2013. In this presentation, I covered the new hotness coming to the web platform and how Dart helps to bring much of to modern browsers today. Encapsulation, templates, custom elements, and dynamic data-driven views are made available thanks to Dart's Web UI library (heavily inspired by Web Components and Model-Driven Views).


The slides are now available. WARNING: You might need Chrome Canary to see all the demos in action.



In the presentation, I covered topics such as:

Web ComponentsShadow DOMCustom elementsDart language and librariesDart's toolchainDart's Web UI library (a polyfill for Web Components and MDV-esque behavior) If you're interested in these topics, you can learn more about Dart and Web UI.
JFokus was a blast. Great conference, friendly crowd, excellent A/V setup! As an old Java developer, it felt good showing off the hotness of modern web development and structured …

Bite-sized Dart videos

Image
For the past month I've been working with Marakana to film and produce short, bite-sized introduction videos for the Dart language and libraries. After filming lots of various videos and formats, I've noticed that viewer retention is difficult. It's so easy to simply click away at any time. Our long-form videos are difficult to watch all the way through. So, we're swinging over to the other end of the spectrum with super-short, targeted videos. The result: Dart Tips, for when you have only 5 minutes to learn something new about Dart.


Six videos have been released so far. Topics include:

Reading a Dart scriptDart runtime modesBuilt-in typesVariablesCollectionsFunctions
You can see the entire playlist for Dart Tips for all the episodes.

For a taste, here's "Functions are fun, pt 1":


Marakana has been great to work with. They are professional, fun, and like to experiment with new techniques. They have a strong training operation, providing classes on Android,…