5.0.4 • Published 10 days ago

@oada/list-lib v5.0.4

Weekly downloads
115
License
Apache-2.0
Repository
github
Last release
10 days ago

OADA/list-lib

A library for handling lists of items in OADA for TypeScript and JavaScript. The library takes callbacks for events like new items, removed items, and changed items. It tried to abstract away as much of the complexity as is reasonable, and tracks which items in the list are new, old, etc.

For detailed options, see the Options type in src/Options.ts

Basic Usage Example

import { ListWatch } from '@oada/list-lib'

// See type definitions for all supported options
const watch = new ListWatch({
    path: '/bookmarks/foo/list',
    name: 'bob',
    conn: /* an @oada/client instance */,
    resume: true,

    onAddItem(item, id) { console.log(`New list item ${id}: %O`, item) },
    onRemoveItem(id) { console.log(`Item ${id} removed`) },
})

// The watch can be stopped after creation
await watch.stop()

Item types

While the ListWatch class is generic, you will typically not want to specify a type paramter in your code. If you supply an assertItem function, the type of Item will be inferred from it. This will help minimize runtime errors (assuming your type assertion is good), and in the case of no assertion the library defaults Item to unknown.

Rechecking items

In more advanced use-cases, you might want to prompt the libray to re-check all the items in the list. For this reason, ListWatch has a forceRecheck method. Calling this will cause the library to check all the current list items.

5.0.4

10 days ago

5.0.3

11 days ago

5.0.2

12 days ago

5.0.1

2 months ago

5.0.0

2 months ago

4.3.0

3 months ago

4.2.5

1 year ago

4.2.6

1 year ago

4.2.3

1 year ago

4.2.4

1 year ago

4.2.2

1 year ago

4.2.1

1 year ago

4.2.0

1 year ago

4.1.4

1 year ago

4.1.3

1 year ago

4.1.0

1 year ago

4.1.2

1 year ago

4.1.1

1 year ago

4.0.1

2 years ago

4.0.0

2 years ago

4.0.2

2 years ago

3.0.9

2 years ago

3.0.4

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.8

2 years ago

3.0.7

2 years ago

3.0.6

2 years ago

3.0.5

2 years ago

3.0.0

2 years ago

2.2.0

2 years ago

2.1.11

2 years ago

2.1.10

3 years ago

2.1.8

3 years ago

2.1.9

3 years ago

2.1.7

3 years ago

2.1.6

3 years ago

2.1.5

3 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.6

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

1.1.1

4 years ago

2.0.0

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago