Added Flutter lib

This commit is contained in:
thosakwe 2017-06-30 18:57:01 -04:00
parent 25da3788f7
commit e08aff9507
4 changed files with 24 additions and 6 deletions

View file

@ -1,11 +1,11 @@
# angel_client # 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) [![build status](https://travis-ci.org/angel-dart/client.svg)](https://travis-ci.org/angel-dart/client)
Client library for the Angel framework. Client library for the Angel framework.
This library provides virtually the same API as an Angel server. 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. In addition, the client supports `angel_auth` authentication.
# Usage # Usage

View file

@ -1,9 +1,9 @@
/// Browser library for the Angel framework. /// Browser client library for the Angel framework.
library angel_client.browser; library angel_client.browser;
import 'dart:async' show Future, Stream, StreamController, StreamSubscription, Timer; import 'dart:async' show Future, Stream, StreamController, StreamSubscription, Timer;
import 'dart:convert' show JSON; 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 'package:http/browser_client.dart' as http;
import 'angel_client.dart'; import 'angel_client.dart';
// import 'auth_types.dart' as auth_types; // import 'auth_types.dart' as auth_types;
@ -69,7 +69,8 @@ class Rest extends BaseAngelClient {
timer.cancel(); 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) { if (!ctrl.isClosed) {
ctrl.add(e.detail); ctrl.add(e.detail);
t.cancel(); t.cancel();

17
lib/flutter.dart Normal file
View file

@ -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<String> authenticateViaPopup(String url, {String eventName: 'token'}) {
throw new UnimplementedError('Opening popup windows is not supported in the `dart:io` client.');
}
}

View file

@ -1,5 +1,5 @@
name: angel_client name: angel_client
version: 1.0.6 version: 1.0.7
description: Client library for the Angel framework. description: Client library for the Angel framework.
author: Tobe O <thosakwe@gmail.com> author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/angel_client homepage: https://github.com/angel-dart/angel_client