From c800235ebba5365649bba20d119f81c95058a6b4 Mon Sep 17 00:00:00 2001 From: evlist Date: Thu, 20 Oct 2022 16:58:33 +0200 Subject: [PATCH] Doc --- src/components/map/TiledLayer.tsx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/map/TiledLayer.tsx b/src/components/map/TiledLayer.tsx index c4b55e0..b513f9c 100644 --- a/src/components/map/TiledLayer.tsx +++ b/src/components/map/TiledLayer.tsx @@ -4,23 +4,20 @@ import { range, isEqual } from 'lodash'; import { Rectangle, TileFactory, TileKeyObject } from './types'; import tileUri from './uris'; +/** + * @hidden + */ export const thisIsAModule = true; /** - * A cache to store tiles without being subject to re-initialization when components are unmounted/remounted. - * - * This cache is a map of map, the first key identifying the ``s. - * - * Idea stolen [on the web](https://dev.to/tiagof/react-re-mounting-vs-re-rendering-lnh) - * - * TODO: housekeeping * */ + declare global { var cacheForTiledLayer: any; } -export {}; +//export {}; globalThis.cacheForTiledLayer = new Map(); @@ -44,8 +41,17 @@ export interface TiledLayerProperties { * This component has no need to know the number nor the size of its tiles: tiles can be added when needed and * its unit is the tile size (the parent component needs to transform its enclosing SVG group to adapt its units) * + * The `globalThis.cacheForTiledLayer` global variable is used as a cache to store tiles without being subject + * to re-initialization when components are unmounted/remounted. + * + * This cache is a map of map, the first key identifying the ``s. + * + * Idea stolen [on the web](https://dev.to/tiagof/react-re-mounting-vs-re-rendering-lnh) + * + * TODO: cache housekeeping + * * TODO: test tiles'X and Y boundaries. - * TODO: housekeeping + * * TODO: remove tileFactory to facilitate memoisation. * */