Skip to content

Commit 91c9690

Browse files
committed
setAddon with querry
1 parent 03ec92d commit 91c9690

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

setAddon/addon_querry.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
import React from 'react';
2+
import { initStore } from '../src';
3+
import { ENQ_ASK } from '../src/store/store';
4+
5+
import config from './config';
6+
7+
const storeEnv = initStore(config);
8+
const setupChannel = storeEnv.channelInit(ENQ_ASK, 'ad02');
9+
const stopChannel = setupChannel();
10+
console.log(storeEnv);
11+
const store = storeEnv.addonStore.getAll();
12+
console.log('store:', store);
13+
let querry = {
14+
chapter: 'undef',
15+
};
16+
const stopQuerySubscription = storeEnv.addonStore.watch('queryData', (data) => {
17+
// console.info('queryData in addon:', data)
18+
querry = data;
19+
});
220

321
const querryManager = {
422
qIndex: 0,
@@ -9,11 +27,14 @@ const querryManager = {
927

1028
const addons = {
1129
querry() {
12-
this.add('querry addon', () => (
13-
<div>
14-
It is a test querry addon {`#${querryManager.getInd()}`}
15-
</div>
16-
))
30+
console.log('store querry:', storeEnv.addonStore.getAll());
31+
this.add('querry addon', () => {
32+
console.log('store select:', storeEnv.addonStore.getAll());
33+
// storeEnv.addonStore.set('queryData', {chapter: 'lalala'});
34+
return (<div>
35+
It is a test querry addon: {`#${querry.chapter}`}
36+
</div>)
37+
})
1738
}
1839
}
1940

setAddon/config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
const ADDON_ID = 'querry';
2-
export default {
2+
const config = {
33
ADDON_ID,
44
ADDON_TITLE: 'Q',
55
PANEL_ID: `${ADDON_ID}/no_panels_here`,
66
EVENT_ID_INIT: `${ADDON_ID}/q/init`,
77
EVENT_ID_DATA: `${ADDON_ID}/q/data`,
88
CSS_CLASS: 'addon-querry',
99
};
10+
export default {
11+
initData: 'QQQ - this is init data',
12+
config,
13+
queryParams: {
14+
chapter: 'no',
15+
},
16+
};

setAddon/register.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { register } from '../src';
2+
import { ENQ_SEND } from '../src/store/store';
23
//import addonApi from './api';
34
import config from './config';
45
//import defaultData from './defaultData';
56
//import panelRoutes from './panelRoutes';
67

7-
const panelSettings = {
8-
initData: 'QQQ - this is init data',
9-
config,
10-
queryParams: {
11-
chapters: 'no',
12-
},
13-
};
148

15-
register(panelSettings);
9+
register(config, (env) => {
10+
console.log(env);
11+
const setupChannel = env.channelInit(ENQ_SEND, 'qq01');
12+
const stopChannel = setupChannel();
13+
});

0 commit comments

Comments
 (0)