The Protevus Platform: Unified Full-Stack Development https://protevus.com
Find a file
2016-06-24 17:07:31 -04:00
lib Done 2016-06-24 17:06:57 -04:00
test Done 2016-06-24 17:06:57 -04:00
.gitignore :) 2016-06-23 20:25:11 -04:00
LICENSE Initial commit 2016-06-23 15:13:52 -04:00
pubspec.yaml Fixed dep 2016-06-24 17:07:31 -04:00
README.md Done 2016-06-24 17:06:57 -04:00

angel_client

Client library for the Angel framework.

Isomorphic

The REST client depends on http, because it can run in the browser or on the command-line. Depending on your environment, you must pass an instance of BaseClient to the constructor.

Usage

This library provides the same API as an Angel server.

import 'package:angel_client/angel_client.dart';
import 'package:http/browser_client.dart';

main() async {
  Angel app = new Rest("http://localhost:3000", new BrowserClient());
}

You can call service to receive an instance of Service, which acts as a client to a service on the server at the given path (say that five times fast!).

foo() async {
  Service Todos = app.service("todos");
  List<Map> todos = await Todos.index();

  print(todos.length);
}

The REST client also supports reflection via json_god. There is no need to work with Maps; you can use the same class on the client and the server.

class Todo extends Model {
  String text;

  Todo({String this.text});
}

bar() async {
  Service Todos = app.service("todos", type: Todo);
  List<Todo> todos = await Todos.index();

  print(todos.length);
}

Just like on the server, services support index, read, create, modify, update and remove.