seltzer 0.0.1 copy "seltzer: ^0.0.1" to clipboard
seltzer: ^0.0.1 copied to clipboard

outdatedDart 1 only

An elegant and rich cross-platform HTTP library for Dart. Unlike most HTTP libraries, most things in Seltzer are a Stream not a Future, this allows extensibility, and adding features like local cachin [...]

Seltzer #

Build Status

An elegant and rich cross-platform HTTP library for Dart.

Getting Started #

You can use Seltzer as an object-oriented HTTP service or simply use top-level convenience methods like get and post directly.

Using the service #

If you are using Seltzer with dependency injection:

import 'dart:async';

import 'package:seltzer/seltzer.dart';
import 'package:seltzer/platform/server.dart';

void main() {
  new MyTwitterService(new ServerSeltzerHttp()).tweet('Hello World!');
}

class MyTwitterService {
  final SeltzerHttp _http;
  
  MyTwitterService(this._http);
  
  // Uses the SeltzerHttp service to send a tweet.
  //
  // This means if we are in the browser or the server we can expect
  // our http service to work about the same.
  Future<Null> tweet(String message) => ...
}

Using top-level methods #

For simpler applications or scripts, Seltzer also provides a series of top-level convenience methods that automatically use a singleton instance of SeltzerHttp.

In your main() function, you just need to configure what platform you are expecting once:

import 'package:seltzer/seltzer.dart' as seltzer;
import 'package:seltzer/platform/browser.dart';

void main() {
  useSeltzerInTheBrowser();
  seltzer.get('some/url.json').send().first.then((response) {
    print('Retrieved: ${response.payload}');
  });
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

An elegant and rich cross-platform HTTP library for Dart. Unlike most HTTP libraries, most things in Seltzer are a Stream not a Future, this allows extensibility, and adding features like local caching, easy. Seltzer is based loosely on the "superagent" package for NodeJs (https://github.com/visionmedia/superagent) and the "streamy" package for Dart (https://github.com/google/streamy-dart).

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

meta

More

Packages that depend on seltzer