From cdf791f0c51d869af31d864e3550569f9d16ae33 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Thu, 28 May 2015 14:55:10 -0700 Subject: [PATCH] feat(facade): add read/write access to global variables --- modules/angular2/src/facade/js_interop.dart | 15 +++++++++++++++ modules/angular2/src/facade/js_interop.ts | 13 +++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 modules/angular2/src/facade/js_interop.dart create mode 100644 modules/angular2/src/facade/js_interop.ts diff --git a/modules/angular2/src/facade/js_interop.dart b/modules/angular2/src/facade/js_interop.dart new file mode 100644 index 0000000000..dd645b534d --- /dev/null +++ b/modules/angular2/src/facade/js_interop.dart @@ -0,0 +1,15 @@ +library angular2.src.facade.js_interop; + +import 'dart:js' as js; + +setGlobalVar(String name, value) { + js.context[name] = value; +} + +getGlobalVar(String name) { + return js.context[name]; +} + +invokeJsFunction(js.JsFunction fn, self, args) { + return fn.apply(args, thisArg: self); +} diff --git a/modules/angular2/src/facade/js_interop.ts b/modules/angular2/src/facade/js_interop.ts new file mode 100644 index 0000000000..38281485bc --- /dev/null +++ b/modules/angular2/src/facade/js_interop.ts @@ -0,0 +1,13 @@ +import {global} from './lang'; + +export function setGlobalVar(name: string, value: any) { + global[name] = value; +} + +export function getGlobalVar(name: string) { + return global[name]; +} + +export function invokeJsFunction(fn: Function, self: any, args: List) { + return fn.apply(self, args); +}