diff --git a/README.md b/README.md index 085aeb78..8f08fd61 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # angel_client -[![pub 1.0.6](https://img.shields.io/badge/pub-1.0.6-brightgreen.svg)](https://pub.dartlang.org/packages/angel_client) +[![Pub](https://img.shields.io/pub/v/angel_client.svg)](https://pub.dartlang.org/packages/angel_client) [![build status](https://travis-ci.org/angel-dart/client.svg)](https://travis-ci.org/angel-dart/client) Client library for the Angel framework. This library provides virtually the same API as an Angel server. -The client can run in the browser or on the command-line. +The client can run in the browser, in Flutter, or on the command-line. In addition, the client supports `angel_auth` authentication. # Usage diff --git a/lib/browser.dart b/lib/browser.dart index 59faf0f3..996eb849 100644 --- a/lib/browser.dart +++ b/lib/browser.dart @@ -1,9 +1,9 @@ -/// Browser library for the Angel framework. +/// Browser client library for the Angel framework. library angel_client.browser; import 'dart:async' show Future, Stream, StreamController, StreamSubscription, Timer; import 'dart:convert' show JSON; -import 'dart:html' show CustomEvent, window; +import 'dart:html' show CustomEvent, Event, window; import 'package:http/browser_client.dart' as http; import 'angel_client.dart'; // import 'auth_types.dart' as auth_types; @@ -69,7 +69,8 @@ class Rest extends BaseAngelClient { timer.cancel(); }); - sub = window.on[eventName ?? 'token'].listen((CustomEvent e) { + sub = window.on[eventName ?? 'token'].listen((Event ev) { + var e = ev as CustomEvent; if (!ctrl.isClosed) { ctrl.add(e.detail); t.cancel(); diff --git a/lib/flutter.dart b/lib/flutter.dart new file mode 100644 index 00000000..3b407932 --- /dev/null +++ b/lib/flutter.dart @@ -0,0 +1,17 @@ +/// Flutter-compatible client library for the Angel framework. +library angel_client.flutter; + +import 'dart:async'; +import 'package:http/http.dart' as http; +import 'base_angel_client.dart'; +export 'angel_client.dart'; + +/// Queries an Angel server via REST. +class Rest extends BaseAngelClient { + Rest(String basePath) : super(new http.Client(), basePath); + + @override + Stream authenticateViaPopup(String url, {String eventName: 'token'}) { + throw new UnimplementedError('Opening popup windows is not supported in the `dart:io` client.'); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 22342d56..3eaaa991 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_client -version: 1.0.6 +version: 1.0.7 description: Client library for the Angel framework. author: Tobe O homepage: https://github.com/angel-dart/angel_client