Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hydration Block Confusion #19

Closed
ken-jen opened this issue Jun 19, 2017 · 2 comments
Closed

Hydration Block Confusion #19

ken-jen opened this issue Jun 19, 2017 · 2 comments

Comments

@ken-jen
Copy link

ken-jen commented Jun 19, 2017

I'm a little lost regarding the intended use of @property (nullable, nonatomic, copy, readonly) TIPImageFetchHydrationBlock imageRequestHydrationBlock; on a TIPImageFetchRequest to modify an NSURLRequest. I would expect this block to have a return type of NSURLRequest, to allow us to process the request that is passed into the block and return the modified output. For example, I am currently trying to insert an authentication entry into the header for OAuth2.

Any tips?

@NSProgrammer
Copy link
Collaborator

To support asynchronous behavior, the hydration block is provided with a completion block.

request.imageRequestHydrationBlock = ^(NSURLRequest *URLRequest, id context, TIPImageFetchHydrationCompletionBlock completion) {
    NSMutableURLRequest *mRequest = [URLRequest copy];
    [mRequest setValue:MyOAuthToken() forHTTPHeaderField:@"Authorization"];
    completion(mRequest, nil);
};

@ken-jen
Copy link
Author

ken-jen commented Jun 20, 2017

Thanks!

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

No branches or pull requests

2 participants