Skip to content

Commit

Permalink
Set configuration cached to true by default
Browse files Browse the repository at this point in the history
  • Loading branch information
desistefanova committed Mar 18, 2022
1 parent 4e172ea commit 6b1fa7b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions flutter/realm_flutter/ios/Classes/RealmPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void dummy(void) {
realm_list_size(NULL, 0);
realm_dart_results_add_notification_callback(NULL, NULL, NULL, NULL);
realm_results_snapshot(NULL);
realm_config_get_cached(NULL);
}

@end
7 changes: 7 additions & 0 deletions lib/src/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
////////////////////////////////////////////////////////////////////////////////
import 'dart:io';
import 'dart:isolate';

import 'native/realm_core.dart';

Expand All @@ -27,6 +28,7 @@ import 'package:path/path.dart' as _path;
/// Configuration used to create a [Realm] instance
/// {@category Configuration}
class Configuration {
final RawReceivePort receivePort = RawReceivePort();
final ConfigHandle _handle;
final RealmSchema _schema;

Expand All @@ -50,6 +52,8 @@ class Configuration {
this.fifoFilesFallbackPath = fifoFilesFallbackPath;
}

_isCached = true;

if (readOnly) {
isReadOnly = true;
}
Expand Down Expand Up @@ -132,6 +136,9 @@ class Configuration {
/// by the [path] you property. This property is ignored if the directory defined by [path] allow FIFO special files.
String get fifoFilesFallbackPath => realmCore.getConfigFifoPath(this);
set fifoFilesFallbackPath(String value) => realmCore.setConfigFifoPath(this, value);

bool get _isCached => realmCore.getConfigCached(this);
set _isCached(bool value) => realmCore.setConfigCached(this, value);
}

/// A collection of properties describing the underlying schema of a [RealmObject].
Expand Down
8 changes: 8 additions & 0 deletions lib/src/native/realm_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ class _RealmCore {
});
}

bool getConfigCached(Configuration config) {
return _realmLib.realm_config_get_cached(config.handle._pointer);
}

void setConfigCached(Configuration config, bool cached) {
_realmLib.realm_config_set_cached(config.handle._pointer, cached);
}

ConfigHandle createConfig() {
final configPtr = _realmLib.realm_config_new();
return ConfigHandle._(configPtr);
Expand Down
1 change: 1 addition & 0 deletions src/realm_dart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void dummy(void) {
realm_list_size(nullptr, 0);
realm_results_add_notification_callback(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
realm_results_snapshot(nullptr);
realm_config_get_cached(nullptr);
#if (ANDROID)
realm_android_dummy();
#endif
Expand Down
1 change: 1 addition & 0 deletions test/realm_object_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ Future<void> main([List<String>? args]) async {
final read = realm.query<Person>("name == 'Kasper'");

expect(read, [person]);
realm.close();
});

test('RealmObject isValid', () {
Expand Down

0 comments on commit 6b1fa7b

Please sign in to comment.