The Protevus Platform: Unified Full-Stack Development https://protevus.com
Find a file
2016-12-13 11:35:35 -05:00
lib More 2016-12-13 11:35:35 -05:00
test More 2016-12-13 11:35:35 -05:00
.babelrc More 2016-12-13 11:35:35 -05:00
.DS_Store Restructured 2016-09-03 08:02:32 -04:00
.gitignore More 2016-12-13 11:35:35 -05:00
.npmignore More 2016-12-13 11:35:35 -05:00
.travis.yml Common code :) 2016-12-08 19:24:07 -05:00
analysis_options.yaml Nearly 2016-12-13 11:34:22 -05:00
LICENSE Initial commit 2016-06-23 15:13:52 -04:00
package.json More 2016-12-13 11:35:35 -05:00
pubspec.yaml More 2016-12-13 11:35:35 -05:00
README.md More 2016-12-13 11:35:35 -05:00

angel_client

pub 1.0.0-dev+21 build status

Client library for the Angel framework.

Isomorphic

The REST client can run in the browser or on the command-line.

Usage

This library provides the same API as an Angel server.

// Choose one or the other, depending on platform
import 'package:angel_client/cli.dart';
import 'package:angel_client/browser.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 CLI 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 {
  // By the next release, this will just be:
  // app.service<Todo>("todos")
  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.