Skip to content

Consolidate loader interfaces - #486

Open
frasercl wants to merge 6 commits into
v5from
refactor/remove-threadable-loader
Open

frasercl wants to merge 6 commits into
v5from
refactor/remove-threadable-loader

Conversation

@frasercl

@frasercl frasercl commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review time: smallish (15-20min)

Problem

For a while, we've made a distinction between IVolumeLoader, the base interface for volume loaders, and ThreadableVolumeLoader, an abstract class which implements IVolumeLoader in terms of lower-level methods that return types that are easier to transfer between threads. This distinction was never super important to maintain — all IVolumeLoaders ended up implemented in terms of ThreadableVolumeLoader from the jump. Now that we're looking at hiding most of the loader API behind Volume rather than making them an explicitly publicly-facing interface, it's a good time to simplify.

Solution

Remove IVolumeLoader; rename ThreadableVolumeLoader to VolumeLoader; use VolumeLoader class where either were previously used.

@frasercl
frasercl requested a review from a team as a code owner October 5, 2026 16:53
@frasercl
frasercl force-pushed the refactor/remove-threadable-loader branch from 479b43e to ea3eead Compare October 5, 2026 20:57
Comment on lines +143 to +149
/**
* By default channel data can arrive out of order and at different times.
* This can cause the rendering to update in a way that is not visually appealing.
* In particular, during time series playback or Z slice playback, we would like
* to see all channels update at the same time.
* @param sync Set true to force all requested channels to load at the same time
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/**
* By default channel data can arrive out of order and at different times.
* This can cause the rendering to update in a way that is not visually appealing.
* In particular, during time series playback or Z slice playback, we would like
* to see all channels update at the same time.
* @param sync Set true to force all requested channels to load at the same time
*/
/**
* Set whether to force all requested channels to load at the same time.
*
* By default channel data can arrive out of order and at different times.
* This can cause the rendering to update in a way that is not visually appealing.
* For example, during time series playback or Z slice playback, we would like
* to see all channels update at the same time.
*/

Really minor nit, but I feel like the wording of the current method string explains the problem first and not what the method actually does? But maybe not important because the method name is descriptive.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the suggested change here removes the @param line

Comment thread src/index.ts
export type { ControlPoint } from "./Lut.js";
export type { CreateLoaderOptions } from "./loaders/index.js";
export type { IVolumeLoader, PerChannelCallback, ThreadableVolumeLoader } from "./loaders/IVolumeLoader.js";
// TODO export `IVolumeLoader`, `ThreadableVolumeLoader` as `VolumeLoader` aliases?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider exporting with a deprecated flag to explain the necessary migration?

Comment thread src/Volume.ts
export type VolumeEvent = {
export type VolumeEvents = {
loadStart: void;
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this exposed as an external API at all?

@frasercl
frasercl added this pull request to stack #500 October 14, 2026 01:52
@frasercl
frasercl requested a balanced review from Copilot October 14, 2026 18:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The consolidation is consistently applied across implementations and consumers, with no blocking issues identified in static review.

0 open findings

What changed in this PR

Simplifies volume loading by replacing IVolumeLoader and ThreadableVolumeLoader with one abstract VolumeLoader class.

Changes:

  • Consolidates the loader contract and documentation.
  • Updates implementations, workers, exports, and demo consumers.
  • Adapts test doubles to the consolidated contract.
File Description
src/​workers/​VolumeLoadWorker.ts Updates worker loader types.
src/​workers/​VolumeLoaderContext.ts Updates worker loader inheritance.
src/​workers/​types.ts Redirects loader type imports.
src/​Volume.ts Uses VolumeLoader; renames event type.
src/​View3d.ts Redirects callback import.
src/​test/​volume.test.ts Updates loader test doubles.
src/​test/​RequestQueue.test.ts Redirects loader utility imports.
src/​loaders/​VolumeLoaderUtils.ts Redirects shared loader imports.
src/​loaders/​VolumeLoader.ts Consolidates contracts and documentation.
src/​loaders/​TiffLoader.ts Uses the consolidated base class.
src/​loaders/​RawArrayLoader.ts Uses the consolidated base class.
src/​loaders/​OpenCellLoader.ts Uses the consolidated base class.
src/​loaders/​OmeZarrLoader.ts Updates inheritance and formatting.
src/​loaders/​JsonImageInfoLoader.ts Uses the consolidated base class.
src/​loaders/​index.ts Updates factory return type.
src/​index.ts Exports consolidated loader type.
public/​types.ts Updates demo state loader type.
public/​index.ts Updates demo loader signatures.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@frasercl frasercl changed the title Refactor/remove threadable loader Consolidate loader interfaces Oct 14, 2026
@frasercl
frasercl force-pushed the refactor/remove-threadable-loader branch from ea3eead to e662fe7 Compare November 11, 2026 01:24
Comment on lines +143 to +149
/**
* By default channel data can arrive out of order and at different times.
* This can cause the rendering to update in a way that is not visually appealing.
* In particular, during time series playback or Z slice playback, we would like
* to see all channels update at the same time.
* @param sync Set true to force all requested channels to load at the same time
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the suggested change here removes the @param line

// TODO make this return a promise that resolves when loading is done?
// TODO this is not cancellable in the sense that any async requests initiated here are not stored
// in a way that they can be interrupted.
// TODO explicitly passing a `LoadSpec` is now rarely useful. Remove?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are these TODOs being addressed? shoudl they be elevated to issue tickets?

This branch has not been deployed

No deployments
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.

5 participants