-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'realm_class.dart'; | ||
import 'native/realm_core.dart'; | ||
|
||
class RealmObjectChanges { | ||
final RealmObjectChangesHandle _handle; | ||
final Realm realm; | ||
|
||
RealmObjectChanges(this._handle, this.realm); | ||
|
||
int? _count; | ||
int get count => _count ??= realmCore.getObjectChangesCount(_handle); | ||
|
||
List<int>? _keys; | ||
List<int> get keys => _keys ??= realmCore.getObjectChanges(_handle, count); | ||
} | ||
|
||
class ObjectChanges<T extends RealmObject> extends RealmObjectChanges { | ||
T _object; | ||
ObjectChanges._(this._object, RealmObjectChangesHandle handle, Realm realm) : super(handle, realm); | ||
|
||
factory ObjectChanges(T object, RealmObjectChanges changes) { | ||
return ObjectChanges._(object, changes._handle, changes.realm); | ||
} | ||
|
||
List<String>? _properties; | ||
List<String> get properties => _properties ??= keys.map((k) => realm.metadata[_object.runtimeType]!.findByKey(k)).toList(); | ||
} | ||
|
||
// TODO: Perhaps let generator generate typed RealmObjectChanges subtypes, | ||
// that can have a much nicer type safe interface | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters