Spec-Zone.ru › Dart 2

dart:js_util

createDartExport<T extends Object> function

Object createDartExport<T extends Object>(
  1. T dartObject
)

Given a Dart object that is marked exportable, creates a JS object literal that forwards to that Dart class. Look at the @JSExport annotation to determine what constitutes "exportable" for a Dart class. The object literal will be a map of export names (which are either the written instance member names or their rename) to their respective Dart instance members.

For example:

@JSExport()
class ExportCounter {
  int value = 0;
  String stringify() => value.toString();
}

@JS()
@staticInterop
class Counter {}

extension on Counter {
  external int get value;
  external set value(int val);
  external String stringify();
}

...

var export = ExportCounter();
var counter = createDartExport(export) as Counter;
export.value = 1;
Expect.isTrue(counter.value, export.value);
Expect.isTrue(counter.stringify(), export.stringify());

Implementation

external Object createDartExport<T extends Object>(T dartObject);

© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.19.6/dart-js_util/createDartExport.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API