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. /// Logs the current user out of the application.
Future logout(); 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}); 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. /// Queries a service on an Angel server, with the same API.
abstract class Service<T> { abstract class Service {
/// Fired on `indexed` events. /// Fired on `indexed` events.
Stream<T> get onIndexed; Stream get onIndexed;
/// Fired on `read` events. /// Fired on `read` events.
Stream<T> get onRead; Stream get onRead;
/// Fired on `created` events. /// Fired on `created` events.
Stream<T> get onCreated; Stream get onCreated;
/// Fired on `modified` events. /// Fired on `modified` events.
Stream<T> get onModified; Stream get onModified;
/// Fired on `updated` events. /// Fired on `updated` events.
Stream<T> get onUpdated; Stream get onUpdated;
/// Fired on `removed` events. /// Fired on `removed` events.
Stream<T> get onRemoved; Stream get onRemoved;
/// The Angel instance powering this service. /// The Angel instance powering this service.
Angel get app; Angel get app;

View file

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

View file

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