Skip to content

Commit 30922f2

Browse files
committed
Update README to enhance clarity on image loading, cancellation, and timeout features
1 parent ccf1204 commit 30922f2

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ await ImageLoader.LoadSprite(imageURL).ThenSet(image);
7272
- [\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_](#____________________)
7373
- [\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_](#____________________-1)
7474
- [\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_](#____________________-2)
75-
- [Other](#other)
76-
- [Understanding `IFuture<T>`](#understanding-ifuturet)
77-
- [Understanding `Reference<T>`](#understanding-referencet)
78-
- [Understanding `Future<Reference<T>>`](#understanding-futurereferencet)
75+
- [Other](#other)
76+
- [Understanding `IFuture<T>`](#understanding-ifuturet)
77+
- [Understanding `Reference<T>`](#understanding-referencet)
78+
- [Understanding `Future<Reference<T>>`](#understanding-futurereferencet)
7979

8080
---
8181

@@ -101,7 +101,7 @@ ImageLoader.Init(); // just once from the main thread
101101

102102
> [Full sample source code](https://github.com/IvanMurzak/Unity-ImageLoader/blob/master/Assets/_PackageRoot/Samples/SampleLifecycle.cs)
103103
104-
`ImageLoader.LoadSprite` returns `IFuture<Sprite>`. This instance provides all range of callbacks and API to modify it. Read more about [Future](#future).
104+
`ImageLoader.LoadSprite` returns `IFuture<Sprite>`. This instance provides all range of callbacks and API to modify it. [Understanding `IFuture<T>`](#understanding-ifuturet).
105105

106106
``` C#
107107
ImageLoader.LoadSprite(imageURL) // loading process started
@@ -207,6 +207,8 @@ ImageLoader.LoadSprite(imageURL).ThenSet(image).Forget();
207207

208208
## Cancellation
209209

210+
Cancellation is helpful if target image consumer doesn't exist anymore. For example the `Image` was destroyed because another level had been loaded. The is not much sense to continue to load the image. It would safe some network traffic, CPU resources, and RAM. `IFuture<T>` provides wide range of options to cancel the ongoing loading process.
211+
210212
> [Full sample source code](https://github.com/IvanMurzak/Unity-ImageLoader/blob/master/Assets/_PackageRoot/Samples/SampleCancellation.cs)
211213
212214
### Cancel by MonoBehaviour events
@@ -282,8 +284,18 @@ ImageLoader.LoadSprite(imageURL) // load sprite
282284

283285
### Timeout
284286

287+
Timeout triggers `IFuture<T>` cancellation.
288+
285289
> [Full sample source code](https://github.com/IvanMurzak/Unity-ImageLoader/blob/master/Assets/_PackageRoot/Samples/SampleTimeout.cs)
286290
291+
Set global timeout in the settings:
292+
293+
``` C#
294+
ImageLoader.settings.timeout = TimeSpan.FromSeconds(30);
295+
```
296+
297+
Set timeout for a specific loading request (`IFuture<T>`):
298+
287299
``` C#
288300
ImageLoader.LoadSprite(imageURL) // load sprite
289301
.ThenSet(image) // if success set sprite into image
@@ -392,10 +404,10 @@ ____________________________
392404
____________________________
393405
```
394406

395-
## Other
407+
# Other
396408

397-
### Understanding `IFuture<T>`
409+
## Understanding `IFuture<T>`
398410

399-
### Understanding `Reference<T>`
411+
## Understanding `Reference<T>`
400412

401-
### Understanding `Future<Reference<T>>`
413+
## Understanding `Future<Reference<T>>`

0 commit comments

Comments
 (0)