Skip to content

Commit

Permalink
Rename classes for more clarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
Janez Stupar committed Nov 6, 2023
1 parent 16906d0 commit da32aa3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/src/batch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ typedef OnChangeFunction = Future<void> Function(
Iterable<String> tables, Hlc hlc);

// Override of Sqflite's Batch class to allow for injection of CRDT logic
class BatchCrdt with SqfliteCrdtImplMixin implements BatchApi {
class BatchSynchroflite with SqfliteCrdtImplMixin implements BatchApi {
final Batch _db;
final bool inTransaction;
int _length = 0;
Expand All @@ -22,7 +22,7 @@ class BatchCrdt with SqfliteCrdtImplMixin implements BatchApi {

final affectedTables = <String>{};

BatchCrdt(this._db, this.canonicalTime, this.onDatasetChanged,
BatchSynchroflite(this._db, this.canonicalTime, this.onDatasetChanged,
{this.inTransaction = false});

void _enqueue(Function statement) {
Expand Down
6 changes: 3 additions & 3 deletions lib/src/transaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// SPDX-License-Identifier: Apache-2.0
part of 'package:synchroflite/synchroflite.dart';

class TransactionSqfliteCrdt extends TransactionCrdt with SqfliteCrdtImplMixin {
class TransactionSynchroflite extends TransactionCrdt with SqfliteCrdtImplMixin {
final SqfliteApi _txn;

TransactionSqfliteCrdt(this._txn, canonicalTime) : super(_txn, canonicalTime);
TransactionSynchroflite(this._txn, canonicalTime) : super(_txn, canonicalTime);

@override
Future<R> _rawInsert<T, R>(T db, InsertStatement statement,
Expand Down Expand Up @@ -50,7 +50,7 @@ class TransactionSqfliteCrdt extends TransactionCrdt with SqfliteCrdtImplMixin {
return _innerRawDelete(_txn, sql, args, canonicalTime);
}

Batch batch() => BatchCrdt(_txn.batch(), canonicalTime, (tables, hlc) async {
Batch batch() => BatchSynchroflite(_txn.batch(), canonicalTime, (tables, hlc) async {
affectedTables.addAll(tables);
}, inTransaction: true);
}
8 changes: 4 additions & 4 deletions lib/synchroflite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ class Synchroflite extends SqlCrdt with SqfliteCrdtImplMixin {
}

Batch batch() =>
BatchCrdt((_db.batch()), canonicalTime.increment(), onDatasetChanged);
BatchSynchroflite((_db.batch()), canonicalTime.increment(), onDatasetChanged);

@override
Future<void> transaction(
Future<void> Function(TransactionSqfliteCrdt txn) action) async {
late final TransactionSqfliteCrdt transaction;
Future<void> Function(TransactionSynchroflite txn) action) async {
late final TransactionSynchroflite transaction;
await _db.transaction((txn) async {
transaction = TransactionSqfliteCrdt(txn, canonicalTime.increment());
transaction = TransactionSynchroflite(txn, canonicalTime.increment());
await action(transaction);
});
// Notify on changes
Expand Down

0 comments on commit da32aa3

Please sign in to comment.