1.0.3
This commit is contained in:
parent
8bb94fdc08
commit
3564fb4e35
3 changed files with 16 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
|||
# angel_client
|
||||
|
||||
[![pub 1.0.2](https://img.shields.io/badge/pub-1.0.2-brightgreen.svg)](https://pub.dartlang.org/packages/angel_client)
|
||||
[![pub 1.0.3](https://img.shields.io/badge/pub-1.0.3-brightgreen.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.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/// Browser library for the Angel framework.
|
||||
library angel_client.browser;
|
||||
|
||||
import 'dart:async' show Future, Stream, StreamController;
|
||||
import 'dart:async' show Future, Stream, StreamController, Timer;
|
||||
import 'dart:convert' show JSON;
|
||||
import 'dart:html' show CustomEvent, window;
|
||||
import 'package:http/browser_client.dart' as http;
|
||||
|
@ -53,21 +53,24 @@ class Rest extends BaseAngelClient {
|
|||
var ctrl = new StreamController<String>();
|
||||
var wnd = window.open(url, 'angel_client_auth_popup');
|
||||
|
||||
wnd
|
||||
..on['beforeunload'].listen((_) {
|
||||
if (!ctrl.isClosed) {
|
||||
new Timer.periodic(new Duration(milliseconds: 500), (timer) {
|
||||
if (!ctrl.isClosed) {
|
||||
if (wnd.closed) {
|
||||
ctrl.addError(new AngelHttpException.notAuthenticated(
|
||||
message:
|
||||
errorMessage ?? 'Authentication via popup window failed.'));
|
||||
ctrl.close();
|
||||
}
|
||||
})
|
||||
..on[eventName ?? 'token'].listen((CustomEvent e) {
|
||||
if (!ctrl.isClosed) {
|
||||
ctrl.add(e.detail);
|
||||
ctrl.close();
|
||||
}
|
||||
});
|
||||
} else
|
||||
timer.cancel();
|
||||
});
|
||||
|
||||
window.on[eventName ?? 'token'].listen((CustomEvent e) {
|
||||
if (!ctrl.isClosed) {
|
||||
ctrl.add(e.detail);
|
||||
ctrl.close();
|
||||
}
|
||||
});
|
||||
|
||||
return ctrl.stream;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel_client
|
||||
version: 1.0.2
|
||||
version: 1.0.3
|
||||
description: Client library for the Angel framework.
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/angel_client
|
||||
|
|
Loading…
Reference in a new issue