Skip to content

Commit 2fe8971

Browse files
authored
Merge pull request #3 from GeekyAnts/fix/changes
Fix/changes
2 parents adb82ca + dd01172 commit 2fe8971

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

example/Plugins/ClickMePlugin.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ class ClickMePlugin implements IPlugin {
99
console.log('Inside init');
1010
this.pluginStore = pluginStore;
1111
}
12+
1213
activate() {
1314
this.pluginStore.addFunction('sendAlert', () => {
1415
alert('Testing');
1516
});
1617

17-
this.pluginStore.executeFunction(
18-
'RendererPlugin.add',
19-
'top',
20-
<h1>asjdf</h1>
21-
);
18+
this.pluginStore.executeFunction('RendererPlugin.add', 'top', () => (
19+
<h1>asdjkdas</h1>
20+
));
2221
}
2322
deactivate() {
2423
//

example/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { createPluginStore, PluginProvider, RendererPlugin } from '../.';
55
import ClickMePlugin from './Plugins/ClickMePlugin';
66
import Test from './components/Test';
77

8-
const App = () => {
9-
const pluginStore = createPluginStore();
10-
pluginStore.install(new RendererPlugin());
11-
pluginStore.install(new ClickMePlugin());
8+
const pluginStore = createPluginStore();
9+
pluginStore.install('RendererPlugin', new RendererPlugin());
10+
pluginStore.install('ClickMePlugin', new ClickMePlugin());
1211

12+
const App = () => {
1313
pluginStore.addFunction('test', (a, b) => {
14-
console.log('working', a, b);
14+
console.log('working 1', a, b);
1515
});
1616
return (
1717
<PluginProvider pluginStore={pluginStore}>

src/PluginStore.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { IPlugin } from './interfaces/IPlugin';
22

33
export class PluginStore {
44
private functionArray: Map<string, any>;
5-
private pluginMap: Array<IPlugin>;
5+
private pluginMap: Map<string, IPlugin>;
66

77
constructor() {
88
this.functionArray = new Map<string, any>();
9-
this.pluginMap = [];
9+
this.pluginMap = new Map<string, IPlugin>();
1010
}
1111

12-
install(plugin: IPlugin) {
13-
this.pluginMap.push(plugin);
12+
install(key: string, plugin: IPlugin) {
13+
this.pluginMap.set(key, plugin);
1414
plugin.init(this);
1515
plugin.activate();
1616
}

src/plugins/RendererPlugin/components/Renderer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export const Renderer: React.SFC<{
1212
);
1313

1414
return (
15-
<React.Fragment>
16-
{components.map((component: any) => (
17-
<>{component}</>
15+
<>
16+
{components.map((Component: any) => (
17+
<Component />
1818
))}
19-
</React.Fragment>
19+
</>
2020
);
2121
};

0 commit comments

Comments
 (0)