@@ -13,7 +13,7 @@ This library covers next aspects that developers should consider for their proje
1313- SVG reusability
1414- Optimized bundle size
1515- SSR
16- - Edge ready (only edge save APIs are used)
16+ - Edge ready (only edge safe APIs are used)
1717
1818## Getting started
1919
@@ -103,7 +103,8 @@ During setup phase you can provide additional optional settings such as:
103103 svgLoadStrategy ?: Type < SvgLoadStrategy > ;
104104```
105105
106- ` svgLoadStrategy ` can be any injectable class that has ` load ` method that accepts url and returns observable string:
106+ ` svgLoadStrategy ` can be any injectable class that has ` config ` that excepts method that accepts url and returns observable string,
107+ and ` load ` which accepts the configured url as an observable and returns the svg as an observable string.
107108
108109``` typescript
109110@Injectable ()
@@ -196,6 +197,36 @@ And then just provide it in you server module.
196197export class AppServerModule {}
197198```
198199
200+ #### Providing a lazy configuration
201+
202+ If you need to provide a lazy configuration you can use the config method in the ` SvgLoadStrategy ` :
203+
204+ ``` typescript
205+ @Injectable ()
206+ class LazyConfigSvgLoadStrategy extends SvgLoadStrategyImpl {
207+ dummyLazyConfig$ = timer (5_000 ).pipe (map (() => ' assets/svg-icons' ))
208+ override config(url : string ): Observable <string > {
209+ return this .dummyLazyConfig$ .pipe (map ((svgConfig ) => ` ${svgConfig }/${url } ` ));
210+ }
211+ }
212+ ```
213+
214+ And pass it to the provider function:
215+
216+ ``` typescript
217+ import { provideFastSVG } from ' @push-based/ngx-fast-svg' ;
218+
219+ bootstrapApplication (AppComponent , {
220+ providers: [
221+ // ... other providers
222+ provideFastSVG ({
223+ url : (name : string ) => ` ${name }.svg ` ,
224+ svgLoadStrategy: LazyConfigSvgLoadStrategy ,
225+ })
226+ ]
227+ });
228+ ```
229+
199230## Features
200231
201232### :sloth : Lazy loading for SVGs
@@ -273,4 +304,3 @@ To display (render) SVGs the browser takes time. We can reduce that time by addi
273304---
274305
275306made with ❤ by [ push-based.io] ( https://www.push-based.io )
276-
0 commit comments