diff --git a/addons/knobs/src/KnobManager.js b/addons/knobs/src/KnobManager.js index 73ae03687e07..adc871568de8 100644 --- a/addons/knobs/src/KnobManager.js +++ b/addons/knobs/src/KnobManager.js @@ -6,11 +6,14 @@ import KnobStore from './KnobStore'; const PANEL_UPDATE_INTERVAL = 400; export default class KnobManager { - constructor(channel) { - this.channel = channel; + constructor() { this.knobStore = new KnobStore(); } + setChannel(channel) { + this.channel = channel; + } + knob(name, options) { this._mayCallChannel(); diff --git a/addons/knobs/src/index.js b/addons/knobs/src/index.js index d508841a8ae4..2f4c16dcddca 100644 --- a/addons/knobs/src/index.js +++ b/addons/knobs/src/index.js @@ -4,8 +4,7 @@ import KnobManager from './KnobManager'; import { vueHandler } from './vue'; import { reactHandler } from './react'; -const channel = addons.getChannel(); -const manager = new KnobManager(channel); +const manager = new KnobManager(); export function knob(name, options) { return manager.knob(name, options); @@ -63,6 +62,9 @@ export function date(name, value = new Date()) { // In 3.3, this will become `withKnobs`, once our decorator API supports it. // See https://github.com/storybooks/storybook/pull/1527 function wrapperKnobs(options) { + const channel = addons.getChannel(); + manager.setChannel(channel); + if (options) channel.emit('addon:knobs:setOptions', options); switch (window.STORYBOOK_ENV) {