Skip to content

Iterate over Store via Map

Via a Map Objects are added to a Svelte Store.

Every object has an ID and it should be possible to iterate over those IDs. With $entities.get(“123”).currentPage;

The current Page of this Object is returned.

How can I iterate over more than one ID such that the current pages of all objects in the store are returned?


You could take those IDs into an array, and then map that array to the code you listed in your question. For example:

function getPages(ids) {
    return => $entitites.get(id).currentPage);
// example call:
let pages = getPages(["123", "146", "195"]);