Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(itemSelection): add support for items getter #27

Merged
merged 1 commit into from
Jun 12, 2024
Merged

Conversation

43081j
Copy link
Owner

@43081j 43081j commented Jun 12, 2024

Sometimes, we need to retrieve the item list dynamically rather than from a constant array we passed at constructor time.

This adds support for passing a function as the items array (() => T[]).

For example:

let items = [];
new ItemSelectionController(this, items);

// re-assign items. this wouldn't affect the controller previously. it
// will still see the original array
items = [a, b];

// instead, we can do this:
new ItemSelectionController(this, () => items);

Sometimes, we need to retrieve the item list dynamically rather than
from a constant array we passed at constructor time.

This adds support for passing a function as the items array (`() =>
T[]`).

For example:

```ts
let items = [];
new ItemSelectionController(this, items);

// re-assign items. this wouldn't affect the controller previously. it
// will still see the original array
items = [a, b];

// instead, we can do this:
new ItemSelectionController(this, () => items);
```
@43081j 43081j merged commit 94b1367 into main Jun 12, 2024
2 checks passed
@43081j 43081j deleted the item-selection-fn branch June 12, 2024 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant