Skip to content
This repository was archived by the owner on May 3, 2021. It is now read-only.

NSProgress instead of blocks #19

Closed
kean opened this issue Jun 29, 2015 · 4 comments
Closed

NSProgress instead of blocks #19

kean opened this issue Jun 29, 2015 · 4 comments
Assignees
Labels
Milestone

Comments

@kean
Copy link
Owner

kean commented Jun 29, 2015

Investigate NSProgress, might not be worth the effort.

@kean kean added the feature label Jun 29, 2015
@kean kean self-assigned this Jun 29, 2015
@kean
Copy link
Owner Author

kean commented Jul 20, 2015

  • Add NSProgress to DFImageTask
  • Support task cancellation using NSProgress object
  • Support implicit progress composition
  • DFImageFetching progress handler should have two arguments: completed and total unit count
  • Support progress tracking for DFPhotosKitImageFetcher
  • _DFImageFetchOperation should propagate current completed and total unit count when new image tasks are added to it

@kean kean added this to the 0.5.1 milestone Jul 20, 2015
@kean kean closed this as completed Jul 20, 2015
@kean kean reopened this Jul 21, 2015
@kean
Copy link
Owner Author

kean commented Jul 21, 2015

Implicit progress composition is supported, here's an example:

NSProgress *progress = [NSProgress progressWithTotalUnitCount:100];

[progress becomeCurrentWithPendingUnitCount:50];
DFImageTask *task1 = [_manager imageTaskForRequest:[DFImageRequest requestWithResource:[TDFMockResource resourceWithID:@"1"]] completion:nil];
[task1 progress]; // force progress creation
[progress resignCurrent];

[progress becomeCurrentWithPendingUnitCount:50];
DFImageTask *task2 = [_manager imageTaskForRequest:[DFImageRequest requestWithResource:[TDFMockResource resourceWithID:@"2"]] completion:nil];
[task2 progress];
[progress resignCurrent];

double __block fractionCompleted = 0;
[self keyValueObservingExpectationForObject:progress keyPath:@"fractionCompleted" handler:^BOOL(NSProgress *observedObject, NSDictionary *change) {
    fractionCompleted += 0.25;
    XCTAssertEqual(fractionCompleted, observedObject.fractionCompleted);
    return observedObject.fractionCompleted == 1;
}];

[task1 resume];
[task2 resume];

[self waitForExpectationsWithTimeout:1 handler:nil];

@kean
Copy link
Owner Author

kean commented Jul 21, 2015

Done

@kean kean closed this as completed Jul 21, 2015
@kean
Copy link
Owner Author

kean commented Jul 25, 2015

Update: progress is now created lazily

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant