Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Classes

Type aliases

Type aliases

ItemStoreOptions

ItemStoreOptions<T>: { getItemId?: (item: T) => string; id: string; onItemAdded?: (item: T) => void }

Type parameters

  • T

Type declaration

  • Optional getItemId?: (item: T) => string

    Function used to get the ID of each item. By default, will use item.id if available

      • (item: T): string
      • Parameters

        • item: T

        Returns string

  • id: string

    ID used for debugging

  • Optional onItemAdded?: (item: T) => void

    Called after an item is added to the store. This can be useful to store an item's related data in other stores.

    Example:

    class UserStore {
     users = new ItemStore<User>({
       onItemAdded: (user) => {
         this.rootStore.mediaStore.add(user.profilePhoto)
       }
     })
    
     constructor(private rootStore) {}
    }
    
      • (item: T): void
      • Parameters

        • item: T

        Returns void

Generated using TypeDoc