-
-
Save digitalfiz/3f431dc07ca761389062 to your computer and use it in GitHub Desktop.
This file contains 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
library projectx; | |
import 'dart:io'; | |
class Container { | |
static Map content = {}; | |
static void set(String name, var contents) { | |
content[name] = contents; | |
} | |
static get(String name) { | |
var test; | |
// I need to know if i should be calling this or returning it. | |
if (content[name] is Function) { | |
test = content[name](); | |
} else { | |
test = content[name]; | |
} | |
return test; | |
} | |
} | |
main() { | |
Container.set('test_closure', (){ | |
DateTime now = new DateTime.now(); | |
return now; | |
}); | |
Container.set('test_string', 'My Test'); | |
Container.set('test_int', 5); | |
Duration wait = new Duration(seconds:1); | |
// Do a couple to see its working | |
print(Container.get('test_closure')); | |
sleep(wait); | |
print(Container.get('test_closure')); | |
sleep(wait); | |
// Should output 'My Test'. | |
print(Container.get('test_string')); | |
// Should output 5. | |
print(Container.get('test_int')); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment