Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,43 @@ | ||||
import { Args } from '@storybook/addons'; | ||||
import { CHANGE_GLOBAL_ARGS, GLOBAL_ARGS_CHANGED } from '@storybook/core-events'; | ||||
|
||||
import { Module, API } from '../index'; | ||||
|
||||
export interface SubState { | ||||
globalArgs: Args; | ||||
} | ||||
|
||||
export interface SubAPI { | ||||
setGlobalArgs: (newGlobalArgs: Args) => void; | ||||
} | ||||
|
||||
const initGlobalArgsApi = ({ store }: Module) => { | ||||
let fullApi: API; | ||||
const setGlobalArgs = (newGlobalArgs: Args) => { | ||||
if (!fullApi) throw new Error('Cannot set global args until api has been initialized'); | ||||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ndelangen
Member
|
export default ({ provider, store, fullAPI }: Module) => { |
That's in my inception branch, but could be ported. I needed this too, and cleaned it up so the init
& scoped let
aren't needed.
This comment has been minimized.
This comment has been minimized.
Sorry, something went wrong.
tmeasday
Mar 3, 2020
Author
Member
Maybe let's clean this up (and a similar spot in shortcuts.js
) when we merge that then. I don't think it's so bad that we need to port it over now.
@ndelangen is there a better way to do this? (I need
fullApi
so I can callfullApi.emit
-- the "smaller" API that is passed intoinitGlobalArgs
does not yet have a channel..