Bye generics

This commit is contained in:
Tobe O 2017-09-24 00:15:40 -04:00
parent eabf105bd6
commit 81c6576458
3 changed files with 27 additions and 27 deletions

View file

@ -44,7 +44,7 @@ abstract class Angel {
/// Logs the current user out of the application.
Future logout();
Service<T> service<T>(String path, {Type type, AngelDeserializer deserializer});
Service service(String path, {Type type, AngelDeserializer deserializer});
Future<http.Response> delete(String url, {Map<String, String> headers});
@ -90,24 +90,24 @@ class AngelAuthResult {
}
/// Queries a service on an Angel server, with the same API.
abstract class Service<T> {
abstract class Service {
/// Fired on `indexed` events.
Stream<T> get onIndexed;
Stream get onIndexed;
/// Fired on `read` events.
Stream<T> get onRead;
Stream get onRead;
/// Fired on `created` events.
Stream<T> get onCreated;
Stream get onCreated;
/// Fired on `modified` events.
Stream<T> get onModified;
Stream get onModified;
/// Fired on `updated` events.
Stream<T> get onUpdated;
Stream get onUpdated;
/// Fired on `removed` events.
Stream<T> get onRemoved;
Stream get onRemoved;
/// The Angel instance powering this service.
Angel get app;

View file

@ -191,10 +191,10 @@ abstract class BaseAngelClient extends Angel {
}
@override
Service<T> service<T>(String path,
Service service(String path,
{Type type, AngelDeserializer deserializer}) {
String uri = path.toString().replaceAll(straySlashes, "");
var s = new BaseAngelService<T>(client, this, '$basePath/$uri',
var s = new BaseAngelService(client, this, '$basePath/$uri',
deserializer: deserializer);
_services.add(s);
return s;
@ -241,37 +241,37 @@ abstract class BaseAngelClient extends Angel {
}
}
class BaseAngelService<T> extends Service<T> {
class BaseAngelService extends Service {
@override
final BaseAngelClient app;
final String basePath;
final http.BaseClient client;
final AngelDeserializer deserializer;
final StreamController<T> _onIndexed = new StreamController<T>(),
_onRead = new StreamController<T>(),
_onCreated = new StreamController<T>(),
_onModified = new StreamController<T>(),
_onUpdated = new StreamController<T>(),
_onRemoved = new StreamController<T>();
final StreamController _onIndexed = new StreamController(),
_onRead = new StreamController(),
_onCreated = new StreamController(),
_onModified = new StreamController(),
_onUpdated = new StreamController(),
_onRemoved = new StreamController();
@override
Stream<T> get onIndexed => _onIndexed.stream;
Stream get onIndexed => _onIndexed.stream;
@override
Stream<T> get onRead => _onRead.stream;
Stream get onRead => _onRead.stream;
@override
Stream<T> get onCreated => _onCreated.stream;
Stream get onCreated => _onCreated.stream;
@override
Stream<T> get onModified => _onModified.stream;
Stream get onModified => _onModified.stream;
@override
Stream<T> get onUpdated => _onUpdated.stream;
Stream get onUpdated => _onUpdated.stream;
@override
Stream<T> get onRemoved => _onRemoved.stream;
Stream get onRemoved => _onRemoved.stream;
@override
Future close() async {

View file

@ -15,10 +15,10 @@ class Rest extends BaseAngelClient {
Rest(String path) : super(new http.Client(), path);
@override
Service<T> service<T>(String path, {Type type, AngelDeserializer deserializer}) {
Service service(String path, {Type type, AngelDeserializer deserializer}) {
String uri = path.replaceAll(straySlashes, "");
var s = new RestService<T>(
client, this, "$basePath/$uri", T != dynamic ? T : type);
var s = new RestService(
client, this, "$basePath/$uri", type);
_services.add(s);
return s;
}
@ -37,7 +37,7 @@ class Rest extends BaseAngelClient {
}
/// Queries an Angel service via REST.
class RestService<T> extends BaseAngelService<T> {
class RestService extends BaseAngelService {
final Type type;
RestService(http.BaseClient client, Angel app, String url, this.type)