Last active
June 9, 2016 16:13
-
-
Save montyr75/5cf202dcc18e528c86caf196dde22bc8 to your computer and use it in GitHub Desktop.
Angular service that acquires information asynchronously, but has dependents waiting for that info. (Pattern)
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
class ConfigService { | |
var _config; | |
Completer _waitForConfig = new Completer(); | |
ConfigService() { | |
doHttpCall().then((result) { | |
_config = result; | |
_waitForConfig.complete(_config); | |
} | |
} | |
Future get config => _waitForConfig.future; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment