mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* added @types/react-native-background-downloader * remove typescript version * modified for lint
29 lines
724 B
TypeScript
29 lines
724 B
TypeScript
import RNBackgroundDownloader from 'react-native-background-downloader';
|
|
|
|
const task = RNBackgroundDownloader.download({
|
|
id: 'file123',
|
|
url: 'https://link-to-very.large/file.zip',
|
|
destination: `${RNBackgroundDownloader.directories.documents}/file.zip`,
|
|
})
|
|
.begin(expectedBytes => {
|
|
console.log(`Going to download ${expectedBytes} bytes!`);
|
|
})
|
|
.progress(percent => {
|
|
console.log(`Downloaded: ${percent * 100}%`);
|
|
})
|
|
.done(() => {
|
|
console.log('Download is done!');
|
|
})
|
|
.error(error => {
|
|
console.log('Download canceled due to error: ', error);
|
|
});
|
|
|
|
// Pause the task
|
|
task.pause();
|
|
|
|
// Resume after pause
|
|
task.resume();
|
|
|
|
// Cancel the task
|
|
task.stop();
|