Skip to content

Commit

Permalink
feat(api): publish traversed spec to gosling api (#978)
Browse files Browse the repository at this point in the history
* feat(api): publish traversed spec to gosling api
* feat(api): rename to specProcessed,
add to eventmap
  • Loading branch information
thomcsmits committed Oct 16, 2023
1 parent a07bb46 commit f17e69f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/compiler/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { UrlToFetchOptions } from 'src/core/gosling-component';
import { renderHiGlass as createHiGlassModels } from './create-higlass-models';
import { manageResponsiveSpecs } from './responsive';
import type { IdTable } from '../api/track-and-view-ids';
import { publish } from '../api/pubsub';

/** The callback function called everytime after the spec has been compiled */
export type CompileCallback = (
Expand Down Expand Up @@ -69,6 +70,13 @@ export function compile(
trackInfos = getRelativeTrackInfo(specCopy, theme).trackInfos;
}

// publish the fixed spec
// used for alt-gosling
publish('specProcessed', {
id: specCopy.id,
spec: specCopy
});

// Make HiGlass models for individual tracks
createHiGlassModels(specCopy, trackInfos, callback, theme, urlToFetchOptions);
}
8 changes: 8 additions & 0 deletions src/gosling-schema/gosling.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,13 @@ interface CommonEventData {
data: Datum[];
}

interface SpecEventData {
/** Source visualization ID, i.e., `track.id` */
id: string;
/** Gosling spec */
spec: GoslingSpec;
}

export interface GenomicPosition {
chromosome: string;
position: number;
Expand Down Expand Up @@ -372,6 +379,7 @@ export type _EventMap = {
click: PointMouseEventData;
rangeSelect: RangeMouseEventData;
rawData: CommonEventData;
specProcessed: SpecEventData;
trackMouseOver: TrackApiData;
trackClick: TrackApiData; // TODO (Jul-25-2022): with https://github.com/higlass/higlass/pull/1098, we can support circular layouts
onNewTrack: OnNewTrackEventData;
Expand Down

0 comments on commit f17e69f

Please sign in to comment.