Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Jun 11, 2017
1 parent 4b6afc2 commit 29cc442
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 37 deletions.
48 changes: 12 additions & 36 deletions Documentation/Guides/Tips and Tricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,16 @@ if imageView.image == nil {

You can also add your own extension method to `Nuke.Manager` that has a placeholder parameter.

## Show a low-res image first and swap to a higher-res one when it arrives

```swift
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellReuseID, for: indexPath)

cell.imageView.image = nil

let placeholder = URL(string: "https://cloud.githubusercontent.com/assets/1567433/18921748/a45de236-85ae-11e6-8c11-f26453e384b6.png")!
manager.loadImage(with: placeholder, into: cell) { [weak cell] response, _ in
guard let cell = cell else { return }
if cell.imageView.image == nil, case let .fulfilled(image) = response {
cell.imageView.image = image
}
}

manager.loadImage(with: Request(url: photos[indexPath.row]), into: cell.imageView)

// In case you want to customize default animation:
//
// manager.loadImage(with: Request(url: photos[indexPath.row]), into: cell.imageView) { [weak cell] response, isFromCache in
// guard let cell = cell else { return }
// guard case let .fulfilled(image) = response else { return }
//
// cell.imageView.image = image
//
// if !isFromCache { // Run cross-fade animations
// let animation = CATransition()
// animation.duration = 0.33
// animation.type = kCATransitionFade
// cell.imageView.layer.add(animation, forKey: "imageTransition")
// }
// }

return cell
}
```
## Using RxNuke

[RxNuke](https://github.com/kean/RxNuke) adds [RxSwift](https://github.com/ReactiveX/RxSwift) extensions for Nuke and enables many common use cases:

- Going From Low to High Resolution
- Loading the First Available Image
- Showing Stale Image While Validating It
- Load Multiple Images, Display All at Once
- Auto Retry
- Tracking Activities

And [many more...](https://github.com/kean/RxNuke#use-cases)
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ A powerful **image loading** and **caching** framework which allows for hassle-f
- Two [cache layers](https://kean.github.io/post/image-caching), fast LRU memory cache
- [Alamofire](https://github.com/kean/Nuke-Alamofire-Plugin), [Gifu](https://github.com/kean/Nuke-Gifu-Plugin), [Toucan](https://github.com/kean/Nuke-Toucan-Plugin) plugins
- [Freedom to use](#h_design) networking, caching libraries of your choice
- [RxSwift](https://github.com/ReactiveX/RxSwift) extensions provided by [RxNuke](https://github.com/kean/RxNuke)
- Automated [prefetching](https://kean.github.io/post/image-preheating) with [Preheat](https://github.com/kean/Preheat) library
- Simple, small (~1k sloc), [fast](https://github.com/kean/Image-Frameworks-Benchmark) and reliable

Expand Down Expand Up @@ -77,7 +78,7 @@ Nuke.loadImage(with: request, into: view) { [weak view] response, _ in
}
```

> The target in this method is declared as `AnyObject` with which the requests get associated. This enables a number of use cases. For example, with a couple lines of code you can [show a low-res image and swap to a higher-res one](https://github.com/kean/Nuke/blob/master/Documentation/Guides/Tips%20and%20Tricks.md#show-a-low-res-image-first-and-swap-to-a-higher-res-one-when-it-arrives) when loaded.
> The target in this method is declared as `AnyObject` with which the requests get associated.

#### Customizing Requests
Expand Down Expand Up @@ -154,6 +155,20 @@ cts.cancel()
```


#### Using RxNuke

[RxNuke](https://github.com/kean/RxNuke) adds [RxSwift](https://github.com/ReactiveX/RxSwift) extensions for Nuke and enables many common use cases:

- Going From Low to High Resolution
- Loading the First Available Image
- Showing Stale Image While Validating It
- Load Multiple Images, Display All at Once
- Auto Retry
- Tracking Activities

And [many more...](https://github.com/kean/RxNuke#use-cases)


#### Using Memory Cache

You can get a directly access to the default memory cache used by Nuke:
Expand Down Expand Up @@ -190,6 +205,10 @@ You can use Nuke in combination with [Preheat](https://github.com/kean/Preheat)

# Plugins<a name="h_plugins"></a>

### [RxNuke](https://github.com/kean/RxNuke)

[RxSwift](https://github.com/ReactiveX/RxSwift) extensions for Nuke with an examples of common use cases solved by Rx.

### [Alamofire Plugin](https://github.com/kean/Nuke-Alamofire-Plugin)

Allows you to replace networking layer with [Alamofire](https://github.com/Alamofire/Alamofire). Combine the power of both frameworks!
Expand Down

0 comments on commit 29cc442

Please sign in to comment.