List
Simple list that can be hooked into React.
Source code is hosted on GitHub
yarn add @corets/listnpm install --save @corets/listSeamless React integration is shipped in a separate package:
useListThere is a version of this package that syncs directly to the localStorage:
createList()
Creates a new instance of observable list:
import { createList } from "@corets/list"
const list = createList(["some", "data"])Create a new instance without the factory function:
import { List } from "@corets/list"
const list = new List(["some", "data"])Create a new instance with a custom differ:
import { createList } from "@corets/list"
const differ = (oldValue, newValue) => true
const list = createList(["some", "data"], { differ })List.get()
Retrieve everything from the list:
List.getAt()
Retrieve a value at the specific index:
List.set()
Replace everything in the list:
List.add()
Append some new values to the list:
List.addAt()
Add a value at the specific index:
List.has()
Check if a specific value is in the list:
List.hasAt()
Check if there is a value at the specific index:
List.remove()
Remove a value from the list:
List.removeAt()
Remove value at the specific index:
List.indexOf()
Get index of a specific value:
List.filter()
Filter values in the list:
List.map()
Map values in the list:
List.forEach()
Iterate over values in the list:
List.listen()
Listen to changes:
Invoke listener immediately:
Listen with a custom differ:
List.use()
Convenience method for people used to React's useState syntax:
Last updated
Was this helpful?