Skip to content

Instantly share code, notes, and snippets.

@jtmuller5
Last active Mar 25, 2021
Embed
What would you like to do?
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