Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
refactor(dccd): Simplify both the interface and the implementation
Browse files Browse the repository at this point in the history
#909 cont'd. This commit is for the map changes (909 is for collection).

Closes #935
  • Loading branch information
vicb authored and mhevery committed Apr 22, 2014
1 parent 400e236 commit 6017db3
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 200 deletions.
38 changes: 5 additions & 33 deletions lib/change_detection/change_detection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,11 @@ abstract class MapChangeRecord<K, V> {
/// The underlying map object
Map get map;

/// A list of [CollectionKeyValue]s which are in the iteration order. */
KeyValue<K, V> get mapHead;
PreviousKeyValue<K, V> get previousMapHead;
/// A list of changed items.
ChangedKeyValue<K, V> get changesHead;
/// A list of new added items.
AddedKeyValue<K, V> get additionsHead;
/// A list of removed items
RemovedKeyValue<K, V> get removalsHead;

void forEachChange(void f(ChangedKeyValue<K, V> change));
void forEachAddition(void f(AddedKeyValue<K, V> addition));
void forEachRemoval(void f(RemovedKeyValue<K, V> removal));
void forEachItem(void f(MapKeyValue<K, V> item));
void forEachPreviousItem(void f(MapKeyValue<K, V> previousItem));
void forEachChange(void f(MapKeyValue<K, V> change));
void forEachAddition(void f(MapKeyValue<K, V> addition));
void forEachRemoval(void f(MapKeyValue<K, V> removal));
}

/**
Expand All @@ -144,26 +136,6 @@ abstract class MapKeyValue<K, V> {
V get currentValue;
}

abstract class KeyValue<K, V> extends MapKeyValue<K, V> {
KeyValue<K, V> get nextKeyValue;
}

abstract class PreviousKeyValue<K, V> extends MapKeyValue<K, V> {
PreviousKeyValue<K, V> get previousNextKeyValue;
}

abstract class AddedKeyValue<K, V> extends MapKeyValue<K, V> {
AddedKeyValue<K, V> get nextAddedKeyValue;
}

abstract class RemovedKeyValue<K, V> extends MapKeyValue<K, V> {
RemovedKeyValue<K, V> get nextRemovedKeyValue;
}

abstract class ChangedKeyValue<K, V> extends MapKeyValue<K, V> {
ChangedKeyValue<K, V> get nextChangedKeyValue;
}

/**
* If the [ChangeDetector] is watching an [Iterable] then the [currentValue] of
* [Record] will contain an instance of [CollectionChangeRecord]. The
Expand Down
Loading

1 comment on commit 6017db3

@jbdeboer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vicb, this change doesn't appear to change the public API -- is that correct?

Please sign in to comment.