rx_model.dart
1.25 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
class Change<T> {
/// Value before change
final T $old;
/// Value after change
final T $new;
final item;
final ListChangeOp op;
final int pos;
final DateTime time;
final int batch;
Change(
{this.$new,
this.$old,
this.batch,
this.item,
this.op,
this.pos,
DateTime time})
: time = time ?? DateTime.now();
String toString() => 'Change(new: ${$new}, old: ${$old})';
Change.insert(
{this.$new, this.$old, this.batch, this.item, this.pos, DateTime time})
: op = ListChangeOp.add,
time = time ?? new DateTime.now();
Change.set(
{this.$new, this.$old, this.batch, this.item, this.pos, DateTime time})
: op = ListChangeOp.set,
time = time ?? new DateTime.now();
Change.remove(
{this.$new, this.$old, this.batch, this.item, this.pos, DateTime time})
: op = ListChangeOp.remove,
time = time ?? new DateTime.now();
Change.clear({this.$new, this.$old, this.batch, DateTime time})
: op = ListChangeOp.clear,
pos = null,
item = null,
time = time ?? new DateTime.now();
}
typedef bool Condition();
typedef E ChildrenListComposer<S, E>(S value);
/// Change operation
enum ListChangeOp { add, remove, clear, set }