Skip to content

Commit

Permalink
feat(history-service): reduce public API surface (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
clebert committed Jan 11, 2019
1 parent 9e8be1e commit 5f8b8ec
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {History} from 'history';
import {
HistoryServiceV1,
RootLocationTransformer,
SharedHistoryService,
defineHistoryService
} from '..';
import {testRootLocationTransformer} from '../internal/test-root-location-transformer';
Expand Down Expand Up @@ -46,9 +45,11 @@ describe('HistoryService#create (on Node.js)', () => {

const sharedHistoryService = defineHistoryService(
testRootLocationTransformer
).create(mockEnv) as SharedHistoryService;
).create(mockEnv);

return sharedHistoryService['1.1'];
return sharedHistoryService['1.1'] as FeatureServiceBinder<
HistoryServiceV1
>;
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
FeatureServiceEnvironment
} from '@feature-hub/core';
import {History} from 'history';
import {HistoryServiceV1, SharedHistoryService, defineHistoryService} from '..';
import {HistoryServiceV1, defineHistoryService} from '..';
import {testRootLocationTransformer} from '../internal/test-root-location-transformer';

const simulateOnPopState = (state: unknown, url: string) => {
Expand Down Expand Up @@ -71,9 +71,11 @@ describe('defineHistoryService', () => {
createHistoryServiceBinder = () => {
const sharedHistoryService = defineHistoryService(
testRootLocationTransformer
).create(mockEnv) as SharedHistoryService;
).create(mockEnv);

return sharedHistoryService['1.1'];
return sharedHistoryService['1.1'] as FeatureServiceBinder<
HistoryServiceV1
>;
};
});

Expand Down
15 changes: 10 additions & 5 deletions packages/history-service/src/define-history-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import {
FeatureServiceProviderDefinition,
SharedFeatureService
} from '@feature-hub/core';
import * as history from 'history';
import {RootLocationTransformer} from './create-root-location-transformer';
import {
HistoryServiceV1,
createHistoryServiceV1Binder
} from './history-service-v1';
import {createHistoryMultiplexers} from './internal/create-history-multiplexers';
import {createHistoryServiceV1Binder} from './internal/create-history-service-v1-binder';

export interface HistoryServiceV1 {
staticRootLocation: history.Location;

createBrowserHistory(): history.History;
createStaticHistory(): history.History;
}

export interface SharedHistoryService extends SharedFeatureService {
interface SharedHistoryService extends SharedFeatureService {
readonly '1.1': FeatureServiceBinder<HistoryServiceV1>;
}

Expand Down
1 change: 0 additions & 1 deletion packages/history-service/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './define-history-service';
export {HistoryServiceV1} from './history-service-v1';
export * from './create-root-location-transformer';
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import {FeatureServiceBinder, FeatureServiceBinding} from '@feature-hub/core';
import * as history from 'history';
import {BrowserConsumerHistory} from './internal/browser-consumer-history';
import {HistoryMultiplexers} from './internal/create-history-multiplexers';
import {StaticConsumerHistory} from './internal/static-consumer-history';

export interface HistoryServiceV1 {
staticRootLocation: history.Location;

createBrowserHistory(): history.History;
createStaticHistory(): history.History;
}
import {HistoryServiceV1} from '../define-history-service';
import {BrowserConsumerHistory} from './browser-consumer-history';
import {HistoryMultiplexers} from './create-history-multiplexers';
import {StaticConsumerHistory} from './static-consumer-history';

export function createHistoryServiceV1Binder(
historyMultiplexers: HistoryMultiplexers
Expand Down

0 comments on commit 5f8b8ec

Please sign in to comment.