1.0.7 • Published 5 years ago

list_lazy_loader v1.0.7

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

ListLazyLoader

  • To manage how items in a list is loaded.
  • run ts-node example/index.ts to try in nodejs (PowerShell).

Remarks

  • Currently focus in typescript's support, will try to finish support's in pure js.
  • examples are a bit messy. but will try my best to update them ASAP.

Usage

import { ListLoader, ListLoaderInterface } from 'ListLazyLoader';
const theList: ListLoaderInterface<ListItem> = new ListLoader<ListItem>(
  setting,
  listLoadFunction,
  eventEmitter
);

Parameters in constructor

setting
propertydefault valuedescription
maxInView_init10max length of list when first loaded
increaseSize10length of list to increase for each loadMore
loadMoreFromExternaltrueload more from listLoadFunction
listUpdateAlgorithm"directAppend"refer to listUpdateAlgorithm
loadMoreRetryInterval1000retry to load more after this time interval if unable to load more
eventsEventObjectrefer to EventObject

listUpdateAlgorithm

  • autoMerge: will filter the list to ensure no duplicated data in the list.
  • directAppend: will directly append the list at the end
  • override: will override the list

EventObject

propertyvaluedescription
loading"loading"when the liast is loading
endOfList"endOfList"when no more item is loaded from listLoadFunction
listUpdated"listUpdated"whenever the list to preview is updated
fullListUpdated"fullListUpdated"whenever the full list is updated
listLoadFunction
  • function to load more item to append into the list
  • () => Promise<ListItem[]|void>
  • ListItem is the type of a single item
eventEmitter
  • function to fire event when properties in EventObject changes
  • leave it as undefined to disable this functionality
  • (eventName: string, details?: any) => void

Methods

  • theList.loadMore(); loads more items into the list;
  • theList.resetList(); resets the list to initial state.
1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago