Skip to content

Commit

Permalink
fix: remove loader store class
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jul 25, 2020
1 parent b4465c3 commit d50e60e
Showing 1 changed file with 7 additions and 46 deletions.
53 changes: 7 additions & 46 deletions core/loader/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import {
StoryPackages,
BuildConfiguration,
RunConfiguration,
Pages,
Document,
defDocType,
DocType,
docStoryToId,
} from '@component-controls/core';
import { LoadingDocStore } from '@component-controls/instrument';

Expand Down Expand Up @@ -39,47 +34,13 @@ export interface LoadingStore {
})[];
}

export class Store implements LoadingStore {
stores: LoadingStore['stores'] = [];
components: LoadingStore['components'] = {};
packages: LoadingStore['packages'] = {};
config: LoadingStore['config'] = {};
buildConfig: LoadingStore['buildConfig'] = {};

constructor(initial?: LoadingStore) {
if (initial) {
this.stores = initial.stores;
this.components = initial.components;
this.packages = initial.packages;
this.config = initial.config;
this.buildConfig = initial.buildConfig;
}
}
getDocs = (docType: DocType): Pages =>
this.stores
.filter(store => {
if (store?.doc) {
const { type = defDocType } = store.doc;
return type === docType;
}
return false;
})
.map(
store =>
({
...store.doc,
stories:
store.doc && store.stories
? Object.keys(store.stories).map(id =>
//@ts-ignore
docStoryToId(store.doc.title, id),
)
: undefined,
} as Document),
);
}

export const store = new Store();
export const store: LoadingStore = {
stores: [],
components: {},
packages: {},
config: {},
buildConfig: {},
};

export const reserveStories = (filePaths: string[]) => {
if (store.stores.length === 0) {
Expand Down

0 comments on commit d50e60e

Please sign in to comment.