platform/lib/shared.dart

44 lines
1.1 KiB
Dart
Raw Normal View History

2016-06-25 18:37:49 +00:00
import 'dart:async';
/// A function that configures an [Angel] client in some way.
typedef Future AngelConfigurer(Angel app);
/// Represents an Angel server that we are querying.
abstract class Angel {
/// The URL of the server.
String basePath;
Angel(String this.basePath);
/// Applies an [AngelConfigurer] to this instance.
Future configure(AngelConfigurer configurer) async {
await configurer(this);
}
/// Returns a representation of a service on the server.
Service service(Pattern path, {Type type});
}
/// Queries a service on an Angel server, with the same API.
abstract class Service {
/// The Angel instance powering this service.
Angel app;
/// Retrieves all resources.
Future<List> index([Map params]);
/// Retrieves the desired resource.
Future read(id, [Map params]);
/// Creates a resource.
Future create(data, [Map params]);
/// Modifies a resource.
Future modify(id, data, [Map params]);
/// Overwrites a resource.
Future update(id, data, [Map params]);
/// Removes the given resource.
Future remove(id, [Map params]);
}