Repository navigation
Expand file tree
/
Copy pathoperation-states.js
More file actions
94 lines (78 loc) · 1.8 KB
/
Copy pathoperation-states.js
File metadata and controls
94 lines (78 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
export default class OperationStates {
constructor(options = {}) {
this.didUpdate = options.didUpdate || (() => {});
this.pushInProgress = false;
this.pullInProgress = false;
this.fetchInProgress = false;
this.commitInProgress = false;
this.checkoutInProgress = false;
}
isPushInProgress() {
return this.pushInProgress;
}
isPullInProgress() {
return this.pullInProgress;
}
isFetchInProgress() {
return this.fetchInProgress;
}
isCommitInProgress() {
return this.commitInProgress;
}
isCheckoutInProgress() {
return this.checkoutInProgress;
}
setPushInProgress(value) {
const oldValue = this.pushInProgress;
this.pushInProgress = value;
if (oldValue !== value) {
this.didUpdate();
}
}
setPullInProgress(value) {
const oldValue = this.pullInProgress;
this.pullInProgress = value;
if (oldValue !== value) {
this.didUpdate();
}
}
setFetchInProgress(value) {
const oldValue = this.fetchInProgress;
this.fetchInProgress = value;
if (oldValue !== value) {
this.didUpdate();
}
}
setCommitInProgress(value) {
const oldValue = this.commitInProgress;
this.commitInProgress = value;
if (oldValue !== value) {
this.didUpdate();
}
}
setCheckoutInProgress(value) {
const oldValue = this.checkoutInProgress;
this.checkoutInProgress = value;
if (oldValue !== value) {
this.didUpdate();
}
}
}
class NullOperationStates extends OperationStates {
setPushInProgress() {
// do nothing
}
setPullInProgress() {
// do nothing
}
setFetchInProgress() {
// do nothing
}
setCommitInProgress() {
// do nothing
}
setCheckoutInProgress() {
// do nothing
}
}
export const nullOperationStates = new NullOperationStates();