Skip to content

Commit 3434e4c

Browse files
updated: doc
1 parent 4694460 commit 3434e4c

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

README.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,33 @@ loadImages($('img', '.main-content'))
5959

6060
```
6161

62-
#### Load sequentially images using a generator
62+
#### Lazy load sequentially images using a generator
6363

6464
```js
6565
import { loadImagesGen } from 'bianco.images-loader'
6666

67-
const loader = loadImagesGen([
68-
'path/to/the/image1.jpg',
69-
'path/to/the/image2.jpg',
70-
'path/to/the/image3.jpg'
71-
])
72-
73-
// load the first image
74-
loader.next().value.then(img => {
75-
// do something with the image
76-
77-
// do something with the remaining images to load
78-
for (let promise of loader) {
79-
promise.then(i => {
80-
// do whathever you want here
81-
})
82-
}
83-
})
67+
const infiniteList = loadImagesGen([...many images])
68+
69+
// load the first 10 images
70+
let i = 10
71+
while (i--) {
72+
infiniteList.next().value.then(onImageLoaded)
73+
}
74+
75+
// do something
76+
77+
// load other 5 images
78+
i = 5
79+
while (i--) {
80+
infiniteList.next().value.then(onImageLoaded)
81+
}
82+
83+
// do something else
84+
85+
// load the remaining images
86+
for (let promise of infiniteList) {
87+
promise.next().value.then(onImageLoaded)
88+
}
8489
```
8590

8691
## API

0 commit comments

Comments
 (0)