Entity lists in Sublay provide powerful feed and list management functionality using Redux state management. The useEntityList hook allows you to create, manage, and filter lists of entities with built-in pagination, caching, and real-time updates.
Each entity list requires a unique listId. This is a client-side identifier that allows multiple independent lists to coexist in your application with their own state, filters, and cached data.Think of listId as creating separate “instances” of entity lists in your Redux store. Each list maintains:
Important: The listId is purely for client-side state management and doesn’t affect which entities are fetched from the server. Use sourceId in your fetch configuration to control which entities are returned from Sublay.
Source IDs (Critical Concept)
Always use sourceId when creating entities. The sourceId logically separates different types of content within your project, preventing them from mixing inappropriately.
Why sourceId Matters
Imagine you’re building an image-sharing app but also have a product blog. Without sourceId:
Your image feed could suddenly show blog articles
Blog subscribers might see random user photos
Content gets mixed unintentionally
With proper sourceId separation:
// When creating entitiesawait createEntity({ title: "Beautiful sunset", content: "Amazing photo from today", sourceId: "image-posts" // Images stay in image feeds});await createEntity({ title: "Product Update v2.0", content: "New features and improvements...", sourceId: "blog-articles" // Articles stay in blog feeds});