import 'dart:async'; import 'package:cake_wallet/utils/mobx.dart'; import 'package:hive/hive.dart'; abstract class Record with Keyable { Record(this._source, this.original) { key = original.key; _listener?.cancel(); _listener = _source.watch(key: original.key).listen((event) { if (!event.deleted) { fromBind(event.value as T); } }); fromBind(original); toBind(original); } dynamic key; @override dynamic get keyIndex => key; final T original; final Box _source; StreamSubscription _listener; void fromBind(T original); void toBind(T original); Future save() => original.save(); }