public cacheCell$()

in src/graph/Graph.ts [409:473]


    public cacheCell$(cellId: string): Observable<Image[]> {
        const cacheCell$ = cellId in this._cachedTiles ?
            observableOf(this) :
            cellId in this._cachingTiles$ ?
                this._cachingTiles$[cellId] :
                this._cacheTile$(cellId);

        return cacheCell$.pipe(
            mergeMap((): Observable<Image[]> => {
                const cachedCell = this._cachedTiles[cellId];
                cachedCell.accessed = new Date().getTime();
                const cellNodes = cachedCell.nodes;

                const fullNodes: Image[] = [];
                const coreNodes: string[] = [];
                for (const node of cellNodes) {
                    if (node.complete) {
                        fullNodes.push(node);
                    } else {
                        coreNodes.push(node.id);
                    }
                }

                const coreNodeBatches: string[][] = [];
                const batchSize: number = 200;
                while (coreNodes.length > 0) {
                    coreNodeBatches.push(coreNodes.splice(0, batchSize));
                }

                const fullNodes$ = observableOf(fullNodes);
                const fillNodes$ = coreNodeBatches
                    .map((batch: string[]): Observable<Image[]> => {
                        return this._api.getSpatialImages$(batch).pipe(
                            map((items: SpatialImagesContract):
                                Image[] => {
                                const filled: Image[] = [];
                                for (const item of items) {
                                    if (!item.node) {
                                        console.warn(
                                            `Image is empty (${item.node})`);
                                        continue;
                                    }

                                    const id = item.node_id;
                                    if (!this.hasNode(id)) { continue; }
                                    const node = this.getNode(id);
                                    if (!node.complete) {
                                        this._makeFull(node, item.node);
                                    }
                                    filled.push(node);
                                }
                                return filled;
                            }));
                    });

                return observableMerge(
                    fullNodes$,
                    observableFrom(fillNodes$).pipe(
                        mergeAll()));
            }),
            reduce(
                (acc: Image[], value: Image[]): Image[] => {
                    return acc.concat(value);
                }));
    }