Skip to content

Add useValues hook#1964

Merged
axelboc merged 2 commits into
mainfrom
use-values
Feb 12, 2026
Merged

Add useValues hook#1964
axelboc merged 2 commits into
mainfrom
use-values

Conversation

@axelboc
Copy link
Copy Markdown
Contributor

@axelboc axelboc commented Feb 11, 2026

Follow-up to #1963 to add a useValues hook.

The old useDatasetsValues and usePrefetchValues hooks were, in the end, quite specific to NeXus in that they accepted arrays of potentially undefined datasets, (Dataset | undefined)[] (for axes and auxiliaries). So I moved them to the nexus pack and renamed them useNxValues and usePrefetchNxValues respectively (see first commit).

This freed up the more generic useValues name for a hook that accepts a record of datasets (i.e. typically the one returned by useDatasets).

Screenshot from 2026-02-11 14-52-49

Each value in the record can also be an object with a dataset and selection key:

const { slice } = useValues({
  slice: { dataset: twoD, selection: '2:0' },
});

Comment thread packages/app/src/vis-packs/nexus/NxNoteFetcher.tsx
@axelboc axelboc requested a review from loichuder February 11, 2026 15:07
Copy link
Copy Markdown
Member

@loichuder loichuder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's so cool 👍

Comment thread packages/app/src/hooks.ts Outdated
Base automatically changed from use-datasets to main February 12, 2026 12:14
@axelboc axelboc merged commit ec5ff1d into main Feb 12, 2026
13 checks passed
@axelboc axelboc deleted the use-values branch February 12, 2026 12:37
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.

2 participants