Skip to content
On this page

Map Creator

If you have many similar stores (for instance, in advanced database ORM), you can define map creator (like a “class” in OOP).

const User = mapCreator((store, id) => {
store.set({ id, isLoading: true })
fetchUser(id).then(data => {
store.set({ id, isLoading: false, data })
})
})
let user1 = User('1')

Imported from the Nano Stores README for version 1.5.5. Improve this page there.