Browse Source

add stream for notifications when objects change.

remove-cryptography-dependency
Herbert Poul 5 years ago
parent
commit
9fdc270bba
  1. 11
      lib/src/kdbx_format.dart

11
lib/src/kdbx_format.dart

@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'dart:typed_data'; import 'dart:typed_data';
@ -76,6 +77,10 @@ class KdbxFile {
final KdbxHeader header; final KdbxHeader header;
final KdbxBody body; final KdbxBody body;
final Set<KdbxObject> dirtyObjects = {}; final Set<KdbxObject> dirtyObjects = {};
final StreamController<Set<KdbxObject>> _dirtyObjectsChanged =
StreamController<Set<KdbxObject>>.broadcast();
Stream<Set<KdbxObject>> get dirtyObjectsChanged =>
_dirtyObjectsChanged.stream;
Uint8List save() { Uint8List save() {
assert(header.versionMajor == 3); assert(header.versionMajor == 3);
@ -93,6 +98,7 @@ class KdbxFile {
.buffer); .buffer);
body.writeV3(writer, this, gen); body.writeV3(writer, this, gen);
dirtyObjects.clear(); dirtyObjects.clear();
_dirtyObjectsChanged.add(dirtyObjects);
return output.toBytes(); return output.toBytes();
} }
@ -103,6 +109,11 @@ class KdbxFile {
void dirtyObject(KdbxObject kdbxObject) { void dirtyObject(KdbxObject kdbxObject) {
dirtyObjects.add(kdbxObject); dirtyObjects.add(kdbxObject);
dirtyObjects.clear();
}
void dispose() {
_dirtyObjectsChanged.close();
} }
// void _subscribeToChildren() { // void _subscribeToChildren() {

Loading…
Cancel
Save