Skip to content

Commit 3824cff

Browse files
committed
Done: Send data back from panel!
1 parent ca70e0c commit 3824cff

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

.storybook/stories.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,26 @@ storiesOf('Storybook Addon Development Kit', module)
2020
.addDecorator(withAdk({ mainColor: 'green' }))
2121
.add(
2222
'Stories',
23-
() => (
24-
<div>
25-
<button>Button 1</button>
26-
</div>
27-
),
23+
() => {
24+
console.log('Render Button 1');
25+
return (
26+
<div>
27+
<button>Button 1</button>
28+
</div>
29+
);
30+
},
2831
adkParams({ currentTheme: 32 })
2932
)
3033
.add(
3134
'Stories2',
32-
() => (
33-
<div>
34-
<button>Button 2</button>
35-
</div>
36-
),
35+
() => {
36+
console.log('Render Button 2');
37+
return (
38+
<div>
39+
<button>Button 2</button>
40+
</div>
41+
);
42+
},
3743
adkParams({ currentTheme: 12 })
3844
);
3945
// .add('Details', () => (

src/ChannelStore.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ export default class ChannelStore {
2020
this.initData = initData;
2121
this.isPanel = isPanel;
2222
this.id = storyId;
23-
24-
console.log(
25-
`New Store Created for ${isPanel ? 'Panel' : 'Preview'}`,
26-
EVENT_ID_INIT,
27-
EVENT_ID_DATA,
28-
EVENT_ID_BACK
29-
);
3023
}
3124

3225
store = {
@@ -74,6 +67,7 @@ export default class ChannelStore {
7467
selectedData.over = selectedData.over || {};
7568
this.selectorId = selectorId;
7669
this.subscriber();
70+
this.send();
7771
};
7872

7973
onDataChannel = updData => {

src/withChannel.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const withChannel = ({
2525
...this.props.initData,
2626
...parameters,
2727
},
28+
isReceived: false,
2829
};
2930

3031
isPanel = this.props.panel || panel;
@@ -38,7 +39,6 @@ const withChannel = ({
3839
storyId,
3940
});
4041

41-
4242
prepareActions = () => {
4343
const {
4444
createGlobalAction: global,
@@ -83,22 +83,24 @@ const withChannel = ({
8383
};
8484

8585
onData = data => {
86-
// this.props.onData(data);
87-
this.setState({ data });
86+
this.setState({ data, isReceived: true });
8887
};
8988

9089
render() {
9190
const { pointName, initData, active, onData, ...props } = this.props;
92-
// console.log('​extends -> render -> this.state.data', this.state.data);
91+
const { data, isReceived } = this.state;
92+
9393
if (active === false) return null;
94+
if (!isReceived) return null;
95+
9496
return (
9597
<WrappedComponent
96-
data={this.state.data}
98+
data={data}
9799
setData={this.store.send}
98100
store={this.store}
99101
active={active}
100102
parameters={parameters}
101-
actions = {this.actions}
103+
actions={this.actions}
102104
{...props}
103105
/>
104106
);

0 commit comments

Comments
 (0)