Skip to content

Instantly share code, notes, and snippets.

@nadako
Last active February 7, 2021 06:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadako/5913724 to your computer and use it in GitHub Desktop.
Save nadako/5913724 to your computer and use it in GitHub Desktop.
A small hack to make JS global variable easily available in Haxe
extern class Globals
{
public static var context(get, never):Context;
inline static function get_context():Context return untyped __js__("context");
}
extern class Context
{
public function doStuff():Void;
}
import Globals.*;
class Main
{
function someMethod()
{
context.doStuff();
}
}
var Main = function() { }
Main.prototype = {
someMethod: function() {
context.doStuff();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment