Skip to content

Commit 0c9d30f

Browse files
Make IsoPass private, update docs.
1 parent a047193 commit 0c9d30f

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

objectbox/lib/src/native/store.dart

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ class Store {
384384

385385
// Isolate entry point must be static or top-level.
386386
static Future<void> _callFunctionWithStoreInIsolate<P, R>(
387-
IsoPass<P, R> isoPass) async {
387+
_IsoPass<P, R> isoPass) async {
388388
final store = Store.attach(isoPass.model, isoPass.dbDirectoryPath,
389389
queriesCaseSensitiveDefault: isoPass.queriesCaseSensitiveDefault);
390390
final result = await isoPass.runFn(store);
@@ -404,7 +404,7 @@ class Store {
404404
// Await isolate spawn to avoid waiting forever if it fails to spawn.
405405
await Isolate.spawn(
406406
_callFunctionWithStoreInIsolate,
407-
IsoPass(_defs, directoryPath, _queriesCaseSensitiveDefault,
407+
_IsoPass(_defs, directoryPath, _queriesCaseSensitiveDefault,
408408
resultPort.sendPort, callback, param));
409409
// Use Completer to return result so type is not lost.
410410
final result = Completer<R>();
@@ -533,36 +533,34 @@ final _nullReturningFn = () => null;
533533
/// Captures everything required to create a "copy" of a store in an isolate
534534
/// and run user code.
535535
@immutable
536-
class IsoPass<P, R> {
537-
///
536+
class _IsoPass<P, R> {
538537
final ModelDefinition model;
539538

540539
/// Used to attach to store in separate isolate
541540
/// (may be replaced in the future).
542541
final String dbDirectoryPath;
543542

544-
/// Config
545543
final bool queriesCaseSensitiveDefault;
546544

547-
/// Non-void functions can use this port to receive the result
545+
/// Non-void functions can use this port to receive the result.
548546
final SendPort? resultPort;
549547

550-
/// Parameter passed to the function
548+
/// Parameter passed to [callback].
551549
final P param;
552550

553-
/// Function to be called in isolate
554-
final FutureOr<R> Function(Store, P) fn;
551+
/// To be called in isolate.
552+
final FutureOr<R> Function(Store, P) callback;
555553

556-
/// creates everything that needs to be passed to the isolate.
557-
const IsoPass(
554+
const _IsoPass(
558555
this.model,
559556
this.dbDirectoryPath,
560557
// ignore: avoid_positional_boolean_parameters
561558
this.queriesCaseSensitiveDefault,
562559
this.resultPort,
563-
this.fn,
560+
this.callback,
564561
this.param);
565562

566-
/// Called inside this class so types are not lost (dynamic instead of P and R).
567-
FutureOr<R> runFn(Store store) => fn(store, param);
563+
/// Calls [callback] inside this class so types are not lost
564+
/// (if called in isolate types would be dynamic instead of P and R).
565+
FutureOr<R> runFn(Store store) => callback(store, param);
568566
}

0 commit comments

Comments
 (0)