Created
February 1, 2017 23:18
-
-
Save bmaurer/fe9d8c1f22774ca42fbf83107bc83dba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var logger; | |
static { | |
logger = new Logger(); | |
console.log('hi'); | |
} | |
export function a() { | |
logger.log("hey"); | |
} |
cc @dominiccooney @domenic @esprehn This is the thing we talked about today for html5 modules.
The idea here is similar to static blocks in Java or C# (https://msdn.microsoft.com/en-us/library/k9x6w0hc.aspx). The idea is that all of the code inside the static {} block would be guaranteed to be executed before any code within the module was executed. As an example:
import { a } from 'a';
console.log('main1');
a();
console.log('main2');
The static block would likely not execute before the main1 log because even though a has been imported, no function inside of it has been used. But it would be guaranteed that inside a() logger is not null because the constructor would at least run before that point.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@groundwater