File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -93,12 +93,15 @@ export class MyMainAppComponent {
93
93
94
94
// disable spinners by default, you can add [spinner]="true" to a specific component instance later on to override this
95
95
imageLoaderConfig .enableSpinner (false );
96
+
97
+ // set the maximum concurrent connections to 10
98
+ imageLoaderConfig .setConcurrency (10 );
96
99
}
97
100
98
101
}
99
102
```
100
103
101
- Below are all the methods that the provider has:
104
+ Below are all the methods that the config provider has:
102
105
103
106
#### enableDebugMode()
104
107
Enables debug mode to receive console logs, errors, warnings.
@@ -134,6 +137,21 @@ Set a custom directory name to store the cached images in.
134
137
#### setConcurrency(concurrency: number)
135
138
Set the maximum number of concurrent connections. Cached images will be loaded instantly, this limit is only for new images.
136
139
140
+ # Clearing the cache
141
+ ``` typescript
142
+
143
+ import { ImageLoader } from ' ionic-image-loader' ;
144
+
145
+ @Component (... )
146
+ class MyComponent {
147
+
148
+ constructor (imageLoader : ImageLoader ) {
149
+ imageLoader .clearCache ();
150
+ }
151
+
152
+ }
153
+
154
+ ```
137
155
138
156
# Contributing
139
157
- ** Having trouble?** Create an issue [ here] ( https://github.com/zyramedia/ionic-image-loader/issues/new )
Original file line number Diff line number Diff line change @@ -52,6 +52,34 @@ export class ImageLoader {
52
52
}
53
53
}
54
54
55
+ /**
56
+ * Clears the cache
57
+ */
58
+ clearCache ( ) : void {
59
+
60
+ const clear = ( ) => {
61
+
62
+ if ( ! this . isInit ) {
63
+ // do not run this method until our service is initialized
64
+ setTimeout ( clear . bind ( this ) , 500 ) ;
65
+ return ;
66
+ }
67
+
68
+ // pause any operations
69
+ this . isInit = false ;
70
+
71
+ File . removeRecursively ( cordova . file . cacheDirectory , this . config . cacheDirectoryName )
72
+ . then ( ( ) => {
73
+ this . initCache ( true ) ;
74
+ } )
75
+ . catch ( this . throwError . bind ( this ) ) ;
76
+
77
+ } ;
78
+
79
+ clear ( ) ;
80
+
81
+ }
82
+
55
83
/**
56
84
* Downloads an image via cordova-plugin-file-transfer
57
85
* @param imageUrl {string} The remote URL of the image
You can’t perform that action at this time.
0 commit comments