Skip to content

Commit 1583db7

Browse files
committed
Switch to single store
1 parent 573c8f3 commit 1583db7

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@storybook/addon-devkit",
3-
"version": "1.0.0-alpha.0",
3+
"version": "1.0.0-alpha.1",
44
"description": "Storybook Addon Development Kit",
55
"author": {
66
"name": "Oleg Proskurin",

src/ChannelStore.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,10 @@ export default class ChannelStore {
150150
this.removeData();
151151
};
152152
}
153+
154+
let singleStore;
155+
156+
export const getSingleStore = (...args) => {
157+
singleStore = singleStore || new ChannelStore(...args)
158+
return singleStore;
159+
};

src/withChannel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
import ChannelStore from './ChannelStore';
3+
import { getSingleStore } from './ChannelStore';
44

55
const getDisplayName = WrappedComponent =>
66
WrappedComponent.displayName || WrappedComponent.name || 'Component';
@@ -45,7 +45,7 @@ const withChannel = ({
4545
isReceived,
4646
};
4747

48-
this.store = new ChannelStore({
48+
this.store = getSingleStore({
4949
EVENT_ID_INIT,
5050
EVENT_ID_DATA,
5151
EVENT_ID_BACK,

0 commit comments

Comments
 (0)