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

REMOVE subscription_store #9228

Merged
merged 3 commits into from
Dec 23, 2019
Merged
Show file tree
Hide file tree
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
28 changes: 1 addition & 27 deletions lib/client-api/src/client_api.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
/* eslint no-underscore-dangle: 0 */
import deprecate from 'util-deprecate';
import isPlainObject from 'is-plain-object';
import { logger } from '@storybook/client-logger';
import addons, { StoryContext, StoryFn, Parameters } from '@storybook/addons';
import Events from '@storybook/core-events';
import { StoryContext, StoryFn, Parameters } from '@storybook/addons';
import { toId } from '@storybook/csf';

import mergeWith from 'lodash/mergeWith';
import isEqual from 'lodash/isEqual';
import get from 'lodash/get';
import { ClientApiParams, DecoratorFunction, ClientApiAddons, StoryApi } from './types';
import subscriptionsStore from './subscriptions_store';
import { applyHooks } from './hooks';
import StoryStore from './story_store';

Expand Down Expand Up @@ -60,28 +57,6 @@ export const defaultDecorateStory = (storyFn: StoryFn, decorators: DecoratorFunc
storyFn
);

const metaSubscriptionHandler = deprecate(
subscriptionsStore.register,
'Events.REGISTER_SUBSCRIPTION is deprecated and will be removed in 6.0. Please use useEffect from @storybook/client-api instead.'
);

const metaSubscription = () => {
addons.getChannel().on(Events.REGISTER_SUBSCRIPTION, metaSubscriptionHandler);
return () =>
addons.getChannel().removeListener(Events.REGISTER_SUBSCRIPTION, metaSubscriptionHandler);
};

const withSubscriptionTracking = (storyFn: StoryFn) => {
if (!addons.hasChannel()) {
return storyFn();
}
subscriptionsStore.markAllAsUnused();
subscriptionsStore.register(metaSubscription);
const result = storyFn();
subscriptionsStore.clearUnused();
return result;
};

let _globalDecorators: DecoratorFunction[] = [];

let _globalParameters: Parameters = {};
Expand Down Expand Up @@ -274,7 +249,6 @@ export default class ClientApi {
...(allParam.decorators || []),
...localDecorators,
..._globalDecorators,
withSubscriptionTracking,
],
}
);
Expand Down
2 changes: 0 additions & 2 deletions lib/client-api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ClientApi, { defaultDecorateStory, addDecorator, addParameters } from './client_api';
import StoryStore from './story_store';
import ConfigApi from './config_api';
import subscriptionsStore from './subscriptions_store';
import pathToId from './pathToId';

import { getQueryParams, getQueryParam } from './queryparams';
Expand All @@ -12,7 +11,6 @@ export {
ClientApi,
StoryStore,
ConfigApi,
subscriptionsStore,
defaultDecorateStory,
pathToId,
getQueryParams,
Expand Down
92 changes: 0 additions & 92 deletions lib/client-api/src/subscriptions_store.test.ts

This file was deleted.

34 changes: 0 additions & 34 deletions lib/client-api/src/subscriptions_store.ts

This file was deleted.