Skip to content

Instantly share code, notes, and snippets.

@montyr75
Last active June 9, 2016 16:13
Show Gist options
  • Save montyr75/5cf202dcc18e528c86caf196dde22bc8 to your computer and use it in GitHub Desktop.
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)
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