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

Add Vizdataset type #993

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 29 additions & 17 deletions app/scripts/components/exploration/types.d.ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,42 +107,54 @@ export interface TimelineDatasetSettings {
// Tile endpoints for the layer given the current map view.
type TimelineDatasetMeta = Record<string, any>;

// TimelineDataset type discriminants
export interface TimelineDatasetIdle {
// Holds only dataset needed for visualization (Subset of timeline dataset)
// @ TODO: Rename Timeline specific variable names
export interface VizDatasetIdle {
status: TimelineDatasetStatus.IDLE;
data: EnhancedDatasetLayer;
error: null;
// User controlled settings like visibility, opacity.
settings: TimelineDatasetSettings;
analysis: TimelineDatasetAnalysisIdle;
meta?: TimelineDatasetMeta;
}
export interface TimelineDatasetLoading {

export interface VizDatasetLoading {
status: TimelineDatasetStatus.LOADING;
data: EnhancedDatasetLayer;
error: null;
// User controlled settings like visibility, opacity.
settings: TimelineDatasetSettings;
analysis: TimelineDatasetAnalysisIdle;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious, what is the goal here? To create a new type to just separate out analysis or to eventually move towards having a clear separation between these Viz & timelinedataset types? If the first, wondering why not something like type VizDatasetIdle = Omit<TimelineDatasetIdle, "analysis"> ?

Copy link
Collaborator Author

@hanbyul-here hanbyul-here Jun 7, 2024

Choose a reason for hiding this comment

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

The goal is to establish the type with attributes only for visualization (for the components needing map visualization), so we can use TimelineDatasets only for Timeline Datasets. (And all other components that only need visualizations - BlockMap, ScrollyMap, s-explore map can use VizDataset)

I think either the current approach or type VizDatasetIdle = Omit<TimelineDatasetIdle, "analysis"> as you suggested works. But in my mind, VizDataset is a more fundamental block and TimelineDataset is the type derived from it - so VizDataset + analysis = TimelineDataset rather than TimelineDataset - analysis = VizDataset.

meta?: TimelineDatasetMeta;
}
export interface TimelineDatasetError {

export interface VizDatasetError {
status: TimelineDatasetStatus.ERROR;
data: EnhancedDatasetLayer;
error: unknown;
// User controlled settings like visibility, opacity.
settings: TimelineDatasetSettings;
analysis: TimelineDatasetAnalysisIdle;
meta?: TimelineDatasetMeta;
}
export interface TimelineDatasetSuccess {
status: TimelineDatasetStatus.SUCCESS;
data: TimelineDatasetData;
error: null;
// User controlled settings like visibility, opacity.
settings: TimelineDatasetSettings;

export interface VizDatasetSuccess {
status: TimelineDatasetStatus.SUCCESS;
data: TimelineDatasetData;
error: null;
settings: TimelineDatasetSettings;
meta?: TimelineDatasetMeta;
}

export type VizDataset = VizDatasetLoading | VizDatasetIdle | VizDatasetError | VizDatasetSuccess;

// TimelineDataset type discriminants
export interface TimelineDatasetIdle extends VizDatasetIdle {
analysis: TimelineDatasetAnalysisIdle;
}
export interface TimelineDatasetLoading extends VizDatasetLoading {
analysis: TimelineDatasetAnalysisIdle;
}
export interface TimelineDatasetError extends VizDatasetError {
analysis: TimelineDatasetAnalysisIdle;
}
export interface TimelineDatasetSuccess extends VizDatasetSuccess {
analysis: TimelineDatasetAnalysis;
meta?: TimelineDatasetMeta;
}

export type TimelineDataset =
Expand Down
Loading