-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add image library to optimize performance
- Loading branch information
1 parent
a411338
commit ae51d38
Showing
2 changed files
with
43 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ImageColor } from '@ui/lib/types/utils/imageColor'; | ||
|
||
class ImageLibrary { | ||
private images: Record<string, ImageColor> = {}; | ||
|
||
public register(hash: string, image: ImageColor) { | ||
this.images[hash] = image; | ||
} | ||
|
||
public get(hash: string): ImageColor | undefined { | ||
return this.images[hash]; | ||
} | ||
|
||
public all(): Record<string, ImageColor> { | ||
return this.images; | ||
} | ||
|
||
public init(images: Record<string, ImageColor>): void { | ||
this.images = images; | ||
} | ||
} | ||
|
||
export const imagesLibrary = new ImageLibrary(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters