Permalink
Browse files

Serializable<T>

  • Loading branch information...
a14n committed Mar 6, 2013
1 parent f8b07e7 commit 0998d8c98687e152e7c9e68b39ab67b513f0b5d1
Showing with 16 additions and 16 deletions.
  1. +12 −12 example/google-maps/marker_simple.dart
  2. +2 −2 lib/js.dart
  3. +2 −2 test/browser_tests.dart
@@ -15,16 +15,16 @@ import 'package:js/js.dart' as js;
final maps = js.retain(js.context.google.maps);
-class LatLng implements js.Serializable {
+class LatLng implements js.Serializable<js.Proxy> {
final js.Proxy _proxy;
LatLng(num lat, num lng) : this._(new js.Proxy(maps.LatLng, lat, lng));
LatLng._(this._proxy);
- toJs() => _proxy;
+ js.Proxy toJs() => _proxy;
}
-class MapTypeId implements js.Serializable {
+class MapTypeId implements js.Serializable<String> {
static final HYBRID = new MapTypeId._(maps.MapTypeId.HYBRID);
static final ROADMAP = new MapTypeId._(maps.MapTypeId.ROADMAP);
static final SATELLITE = new MapTypeId._(maps.MapTypeId.SATELLITE);
@@ -34,10 +34,10 @@ class MapTypeId implements js.Serializable {
MapTypeId._(this._value);
- toJs() => this._value;
+ String toJs() => this._value;
}
-class MapOptions implements js.Serializable {
+class MapOptions implements js.Serializable<js.Proxy> {
final js.Proxy _proxy;
MapOptions() : this._(new js.Proxy(js.context.Object));
@@ -47,10 +47,10 @@ class MapOptions implements js.Serializable {
set mapTypeId(MapTypeId mapTypeId) => _proxy.mapTypeId = mapTypeId;
set zoom(num zoom) => _proxy.zoom = zoom;
- toJs() => _proxy;
+ js.Proxy toJs() => _proxy;
}
-class GMap implements js.Serializable {
+class GMap implements js.Serializable<js.Proxy> {
final js.Proxy _proxy;
GMap(Element container, MapOptions options) : this._(new js.Proxy(maps.Map, container, options));
@@ -60,10 +60,10 @@ class GMap implements js.Serializable {
set mapTypeId(MapTypeId mapTypeId) => _proxy.mapTypeId = mapTypeId;
set zoom(num zoom) => _proxy.zoom = zoom;
- toJs() => _proxy;
+ js.Proxy toJs() => _proxy;
}
-class MarkerOptions implements js.Serializable {
+class MarkerOptions implements js.Serializable<js.Proxy> {
final js.Proxy _proxy;
MarkerOptions() : this._(new js.Proxy(js.context.Object));
@@ -73,16 +73,16 @@ class MarkerOptions implements js.Serializable {
set map(GMap map) => _proxy.map = map;
set title(String title) => _proxy.title = title;
- toJs() => _proxy;
+ js.Proxy toJs() => _proxy;
}
-class Marker implements js.Serializable {
+class Marker implements js.Serializable<js.Proxy> {
final js.Proxy _proxy;
Marker(MarkerOptions options) : this._(new js.Proxy(maps.Marker, options));
Marker._(this._proxy);
- toJs() => _proxy;
+ js.Proxy toJs() => _proxy;
}
void main() {
View
@@ -963,8 +963,8 @@ class FunctionProxy extends Proxy /*implements Function*/ {
/// Marker class used to indicate it is serializable to js. If a class is a
/// [Serializable] the "toJs" method will be called and the result will be used
/// as value.
-abstract class Serializable {
- dynamic toJs();
+abstract class Serializable<T> {
+ T toJs();
}
// A table to managed local Dart objects that are proxied in JavaScript.
View
@@ -10,12 +10,12 @@ import 'package:js/js.dart' as js;
import 'package:unittest/unittest.dart';
import 'package:unittest/html_config.dart';
-class Color implements js.Serializable {
+class Color implements js.Serializable<String> {
static final RED = new Color._("red");
static final BLUE = new Color._("blue");
String _value;
Color._(this._value);
- toJs() => this._value;
+ String toJs() => this._value;
}
main() {

0 comments on commit 0998d8c

Please sign in to comment.