Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tberman authored and smkhalsa committed May 19, 2021
1 parent ea0b48f commit 67628d5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
9 changes: 4 additions & 5 deletions ferry_cache/lib/src/cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ class Cache {

Cache({
Store? store,
utils.DataIdResolver? dataIdFromObject,
this.dataIdFromObject,
this.typePolicies = const {},
this.addTypename = true,
Map<OperationRequest, Map<String, Map<String, dynamic>?>>
seedOptimisticPatches = const {},
}) : store = store ?? MemoryStore(),
optimisticPatchesStream = BehaviorSubject.seeded(seedOptimisticPatches),
dataIdFromObject = dataIdFromObject;
optimisticPatchesStream = BehaviorSubject.seeded(seedOptimisticPatches);

/// Reads data for the given [dataId] from the [Store], merging in any data from optimistic patches
@visibleForTesting
Expand Down Expand Up @@ -65,7 +64,7 @@ class Cache {
store,
typePolicies,
addTypename,
dataIdFromObject: dataIdFromObject,
dataIdFromObject,
).doOnDone(() => closed = true);

return NeverStream<TData?>()
Expand Down Expand Up @@ -101,7 +100,7 @@ class Cache {
store,
typePolicies,
addTypename,
dataIdFromObject: dataIdFromObject,
dataIdFromObject,
).doOnDone(() => closed = true);

return NeverStream<TData?>()
Expand Down
19 changes: 10 additions & 9 deletions ferry_cache/lib/src/fragment_data_change_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ import './utils/data_for_id_stream.dart';

/// Emits when the data for this fragment changes, returning a `Set` of changed IDs.
Stream<Set<String>> fragmentDataChangeStream<TData, TVars>(
FragmentRequest<TData, TVars> request,
bool optimistic,
Stream<Map<OperationRequest, Map<String, Map<String, dynamic>?>>?>
optimisticPatchesStream,
Map<String, dynamic>? Function(String dataId) optimisticReader,
Store store,
Map<String, TypePolicy> typePolicies,
bool addTypename,
{DataIdResolver? dataIdFromObject}) {
FragmentRequest<TData, TVars> request,
bool optimistic,
Stream<Map<OperationRequest, Map<String, Map<String, dynamic>?>>?>
optimisticPatchesStream,
Map<String, dynamic>? Function(String dataId) optimisticReader,
Store store,
Map<String, TypePolicy> typePolicies,
bool addTypename,
DataIdResolver? dataIdFromObject,
) {
final dataIds = <String>{};

denormalizeFragment(
Expand Down
19 changes: 10 additions & 9 deletions ferry_cache/lib/src/operation_data_change_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ import './utils/operation_root_data.dart';

/// Emits when the data for this request changes, returning a `Set` of changed IDs.
Stream<Set<String>> operationDataChangeStream<TData, TVars>(
OperationRequest<TData, TVars> request,
bool optimistic,
Stream<Map<OperationRequest, Map<String, Map<String, dynamic>?>>?>
optimisticPatchesStream,
Map<String, dynamic>? Function(String dataId) optimisticReader,
Store store,
Map<String, TypePolicy> typePolicies,
bool addTypename,
{DataIdResolver? dataIdFromObject}) {
OperationRequest<TData, TVars> request,
bool optimistic,
Stream<Map<OperationRequest, Map<String, Map<String, dynamic>?>>?>
optimisticPatchesStream,
Map<String, dynamic>? Function(String dataId) optimisticReader,
Store store,
Map<String, TypePolicy> typePolicies,
bool addTypename,
DataIdResolver? dataIdFromObject,
) {
final operationDefinition = getOperationDefinition(
request.operation.document,
request.operation.operationName,
Expand Down
13 changes: 13 additions & 0 deletions ferry_cache/test/data_change_streams_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ void main() {
cache.store,
{},
true,
null,
);

expect(
Expand All @@ -87,6 +88,7 @@ void main() {
cache.store,
{},
true,
null,
);

expect(stream, emitsInOrder([emitsDone]));
Expand All @@ -110,6 +112,7 @@ void main() {
cache.store,
{},
true,
null,
);

expect(stream, emitsInOrder([emitsDone]));
Expand All @@ -130,6 +133,7 @@ void main() {
cache.store,
{},
true,
null,
);

expect(stream, emitsInOrder([emitsDone]));
Expand All @@ -153,6 +157,7 @@ void main() {
cache.store,
{},
true,
null,
);

expect(
Expand Down Expand Up @@ -184,6 +189,7 @@ void main() {
cache.store,
{},
true,
null,
);

expect(
Expand Down Expand Up @@ -218,6 +224,7 @@ void main() {
cache.store,
{},
true,
null,
);

expect(stream, emitsInOrder([emitsDone]));
Expand Down Expand Up @@ -247,6 +254,7 @@ void main() {
cache.store,
{},
true,
null,
);

expect(
Expand Down Expand Up @@ -282,6 +290,7 @@ void main() {
cache.store,
{},
true,
null,
);

expect(
Expand Down Expand Up @@ -318,6 +327,7 @@ void main() {
cache.store,
{},
true,
null,
);

expect(
Expand All @@ -338,6 +348,7 @@ void main() {
cache.store,
{},
true,
null,
);

expect(stream, emitsInOrder([emitsDone]));
Expand All @@ -358,6 +369,7 @@ void main() {
cache.store,
{},
true,
null,
);

expect(
Expand Down Expand Up @@ -388,6 +400,7 @@ void main() {
cache.store,
{},
true,
null,
);

expect(
Expand Down

0 comments on commit 67628d5

Please sign in to comment.