Skip to content

Instantly share code, notes, and snippets.

@jtmuller5
Last active March 25, 2021 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtmuller5/57155be80211fb0134a4ea59835a10a0 to your computer and use it in GitHub Desktop.
Save jtmuller5/57155be80211fb0134a4ea59835a10a0 to your computer and use it in GitHub Desktop.
Future<void> initialize() async {
String privateKey = await atProtocolService.getPrivateKey(atProtocolService.currentAtSign);
try {
atProtocolService.atClientImpl.startMonitor(privateKey, printResult);
} on ConnectionInvalidException catch (e){
print('connection error: '+ e.toString());
}
}
Future<void> printResult(String val) async {
print('Monitor result: ' + val.toString());
getNewValue('one');
}
Future<void> getNewValue(String key) async {
AtKey atKey = AtKey();
atKey.key = key;
// Get keys shared by the other sign
atKey.sharedBy = AtConstants().atMap[atProtocolService.currentAtSign];
try {
String serverValue = await atProtocolService.get(atKey);
print('Server value: ' + serverValue.toString());
one = serverValue ?? '-';
} on UnAuthenticatedException catch (e){
print('auth error: '+ e.message);
}
notifyListeners();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment