1 | import { STORIES_COLLAPSE_ALL, STORIES_EXPAND_ALL } from '@storybook/core-events';
|
2 | export const init = ({
|
3 | provider
|
4 | }) => {
|
5 | const api = {
|
6 | getChannel: () => provider.channel,
|
7 | on: (type, cb) => {
|
8 | provider.channel.addListener(type, cb);
|
9 | return () => provider.channel.removeListener(type, cb);
|
10 | },
|
11 | off: (type, cb) => provider.channel.removeListener(type, cb),
|
12 | once: (type, cb) => provider.channel.once(type, cb),
|
13 | emit: (type, ...args) => provider.channel.emit(type, ...args),
|
14 | collapseAll: () => {
|
15 | provider.channel.emit(STORIES_COLLAPSE_ALL, {});
|
16 | },
|
17 | expandAll: () => {
|
18 | api.emit(STORIES_EXPAND_ALL);
|
19 | }
|
20 | };
|
21 | return {
|
22 | api
|
23 | };
|
24 | }; |
\ | No newline at end of file |