Skip to content

Commit ce4b916

Browse files
committed
chore(*): Use the newly introduced Action interface where possible
1 parent ae0e6aa commit ce4b916

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

projects/igniteui-angular/src/lib/services/transaction/igx-transaction.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { Transaction, State, TransactionType, StateUpdateEvent, TransactionEventOrigin } from './transaction';
1+
import { Transaction, State, TransactionType, StateUpdateEvent, TransactionEventOrigin, Action } from './transaction';
22
import { IgxBaseTransactionService } from './base-transaction';
33
import { EventEmitter, Injectable } from '@angular/core';
44
import { isObject, mergeObjects, cloneValue } from '../../core/utils';
55

66
@Injectable()
77
export class IgxTransactionService<T extends Transaction, S extends State> extends IgxBaseTransactionService<T, S> {
88
protected _transactions: T[] = [];
9-
protected _redoStack: { transaction: T, recordRef: any }[][] = [];
10-
protected _undoStack: { transaction: T, recordRef: any }[][] = [];
9+
protected _redoStack: Action<T>[][] = [];
10+
protected _undoStack: Action<T>[][] = [];
1111
protected _states: Map<any, S> = new Map();
1212

1313
/**
@@ -116,7 +116,7 @@ export class IgxTransactionService<T extends Transaction, S extends State> exten
116116
public endPending(commit: boolean): void {
117117
this._isPending = false;
118118
if (commit) {
119-
const actions: { transaction: T, recordRef: any }[] = [];
119+
const actions: Action<T>[] = [];
120120
// don't use addTransaction due to custom undo handling
121121
for (const transaction of this._pendingTransactions) {
122122
const pendingState = this._pendingStates.get(transaction.id);
@@ -179,7 +179,7 @@ export class IgxTransactionService<T extends Transaction, S extends State> exten
179179
return;
180180
}
181181

182-
const lastActions: { transaction: T, recordRef: any }[] = this._undoStack.pop();
182+
const lastActions: Action<T>[] = this._undoStack.pop();
183183
this._transactions.splice(this._transactions.length - lastActions.length);
184184
this._redoStack.push(lastActions);
185185

@@ -198,7 +198,7 @@ export class IgxTransactionService<T extends Transaction, S extends State> exten
198198
*/
199199
public redo(): void {
200200
if (this._redoStack.length > 0) {
201-
let actions: { transaction: T, recordRef: any, useInUndo?: boolean }[];
201+
let actions: Action<T>[];
202202
actions = this._redoStack.pop();
203203
for (const action of actions) {
204204
this.updateState(this._states, action.transaction, action.recordRef);

projects/igniteui-angular/src/lib/services/transaction/transaction.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ export interface State {
3535
type: TransactionType;
3636
}
3737

38-
export interface Action {
39-
transaction: Transaction;
38+
export interface Action<T extends Transaction> {
39+
transaction: T;
4040
recordRef: any;
4141
}
4242

4343
export interface StateUpdateEvent {
4444
origin: TransactionEventOrigin;
45-
actions: Array<Action>;
45+
actions: Action<Transaction>[];
4646
}
4747

4848
/**

0 commit comments

Comments
 (0)