From 9fdc270bba445d8d1df362c4364e2242bc04b18c Mon Sep 17 00:00:00 2001 From: Herbert Poul Date: Wed, 4 Sep 2019 02:08:46 +0200 Subject: [PATCH] add stream for notifications when objects change. --- lib/src/kdbx_format.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/src/kdbx_format.dart b/lib/src/kdbx_format.dart index 44ad022..a7de59e 100644 --- a/lib/src/kdbx_format.dart +++ b/lib/src/kdbx_format.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'dart:typed_data'; @@ -76,6 +77,10 @@ class KdbxFile { final KdbxHeader header; final KdbxBody body; final Set dirtyObjects = {}; + final StreamController> _dirtyObjectsChanged = + StreamController>.broadcast(); + Stream> get dirtyObjectsChanged => + _dirtyObjectsChanged.stream; Uint8List save() { assert(header.versionMajor == 3); @@ -93,6 +98,7 @@ class KdbxFile { .buffer); body.writeV3(writer, this, gen); dirtyObjects.clear(); + _dirtyObjectsChanged.add(dirtyObjects); return output.toBytes(); } @@ -103,6 +109,11 @@ class KdbxFile { void dirtyObject(KdbxObject kdbxObject) { dirtyObjects.add(kdbxObject); + dirtyObjects.clear(); + } + + void dispose() { + _dirtyObjectsChanged.close(); } // void _subscribeToChildren() {