Skip to content

Commit

Permalink
Use plugin events instead of simple strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Orlando Hohmeier committed Feb 9, 2016
1 parent 3b110b4 commit 37ee8ba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/js/plugin/PluginLoader.js
Expand Up @@ -45,7 +45,7 @@ const PluginLoader = {
});

let dispatchToken = PluginDispatcher.register(function (event) {
if (event.eventType === "STARTUP_COMPLETE"
if (event.eventType === PluginEvents.STARTUP_COMPLETE
&& event.pluginId === pluginId) {
PluginDispatcher.unregister(dispatchToken);

Expand Down
3 changes: 2 additions & 1 deletion src/js/plugin/external/PluginEvents.js
Expand Up @@ -2,6 +2,7 @@ import Util from "../../helpers/Util";

const PluginEvents = Util.objectCreateWithAdder("PLUGIN_EVENTS_");

["APPS_STORE_CHANGE"].forEach(PluginEvents.add);
["STARTUP_COMPLETE", "INJECT_COMPONENT","APPS_STORE_CHANGE"]
.forEach(PluginEvents.add);

export default PluginEvents;
3 changes: 2 additions & 1 deletion src/js/stores/PluginComponentStore.js
Expand Up @@ -2,6 +2,7 @@ import {EventEmitter} from "events";
import React from "react/addons";

import PluginDispatcher from "../plugin/external/PluginDispatcher";
import PluginEvents from "../plugin/external/PluginEvents";
import PluginComponentEvents from "../events/PluginComponentEvents";

import Util from "../helpers/Util";
Expand All @@ -15,7 +16,7 @@ var PluginComponentStore = Util.extendObject(EventEmitter.prototype, {
});

PluginDispatcher.register(event => {
if (event.eventType === "INJECT_COMPONENT") {
if (event.eventType === PluginEvents.INJECT_COMPONENT) {
let componentObj = {
placeId: event.placeId,
component: event.component
Expand Down

0 comments on commit 37ee8ba

Please sign in to comment.