Lawndart helps you write offline web apps

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.

These things are seriously dangerous. The toy, not the source code.

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 websql
  • Future-based APIs
  • Tests
  • Example 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');  
  .then((_) => store.nuke())  
  .then((_) =>, "hello"))  
  .then((_) =>"is fun", "dart"))  
  .then((_) => store.getByKey("hello"))  
  .then((value) => query('#$id').text = value);  

Thanks to Futures, the APIs can be chained. All methods in Lawndart return a Future for asynchronous behavior.

You can install Lawndart from pub, Dart's package manager. Simply add a dependency to lawndart in your pubspec.yaml file:

 name: your_cool_app  
  lawndart: any  

Lawndart is open source and hosted on Github. Pull requests are much appreciated, as are bugs and feature requests.

Please try Lawndart and let me know what you think!

Photo Credit: cc

Popular posts from this blog

Lists and arrays in Dart

Converting Array to List in Scala

Null-aware operators in Dart