restructuring brain set up
parent
327cb7a25d
commit
bdc84bc330
@ -0,0 +1,28 @@
|
||||
export const MEMBER_STATUS = "memberStatus";
|
||||
export const LOGIN_STATUS = 'loginStatus';
|
||||
export const SUPPORTER_FOUND = 'SUPPORTER FOUND';
|
||||
export const SUPPORTER_LISTED = 'SUPPORTER LISTED';
|
||||
export const SUPPORTER_NOT_FOUND = 'SUPPORTER NOT FOUND';
|
||||
export const MEMBER_ADDED = 'MEMBER ADDED';
|
||||
export const MEMBER_NOT_ADDED = 'MEMBER NOT ADDED';
|
||||
export const MEMBER_LOGIN_GOOD = 'MEMBER LOGIN GOOD';
|
||||
export const MEMBER_LOGIN_LAME = 'MEMBER LOGIN LAME';
|
||||
export const MEMBER_EXISTS = 'USER ALREADY EXISTS';
|
||||
export const MEMBER_LOGIN_MISSING = 'Missing credentials';
|
||||
|
||||
|
||||
|
||||
class AuthEvent
|
||||
{
|
||||
|
||||
//--------------------------
|
||||
// methods
|
||||
//--------------------------
|
||||
|
||||
|
||||
|
||||
//--------------------------
|
||||
// event handlers
|
||||
//--------------------------
|
||||
}
|
||||
export default new AuthEvent
|
@ -0,0 +1,37 @@
|
||||
export const REQUEST_GOOD = 'requestGood';
|
||||
export const REQUEST_LAME = 'requestLame';
|
||||
export const IMG_REQUEST_GOOD = 'imgRequestGood';
|
||||
export const IMG_REQUEST_LAME = 'imgRequestLame';
|
||||
export const SETTINGS_LOADED = 'dataLoaded';
|
||||
export const HTML_LOADED = 'htmlLoaded';
|
||||
export const ARCHIVES_JSON_LOADED = 'archivesJSONLoaded';
|
||||
export const ARCHIVES_PAGE_LOADED = 'archivesPAGELoaded';
|
||||
export const ARCHIVES_ENTRY_LOADED = 'archivesEntryLoaded';
|
||||
export const PROJECT_UPDATED = 'projectUpdated';
|
||||
export const PROJECT_ADDED = 'projectAdded';
|
||||
export const PROJECTS_SORTED = 'projectsSorted';
|
||||
export const POST_IMAGE_ADDED = 'postImageAdded';
|
||||
export const FEATURE_IMAGE_ADDED = 'featureImageAdded';
|
||||
export const POST_ERROR = 'postError';
|
||||
export const POST_ADDED = 'postAdded';
|
||||
export const POST_UPDATED = 'postUpdated';
|
||||
export const POST_DELETED = 'postImageAdded';
|
||||
export const POSTS_SYNCED = 'postsSynced';
|
||||
export const LOCAL_DB_READY = 'localDBReady';
|
||||
export const SETTINGS_UPDATED = 'settingsUpdated';
|
||||
export const AVATAR_UPLOADED = 'avatarUploaded';
|
||||
export const SITE_BACKGROUND_UPLOADED = 'siteBackgroundUploaded';
|
||||
class DataEvent
|
||||
{
|
||||
|
||||
//--------------------------
|
||||
// methods
|
||||
//--------------------------
|
||||
|
||||
|
||||
|
||||
//--------------------------
|
||||
// event handlers
|
||||
//--------------------------
|
||||
}
|
||||
export default new DataEvent
|
@ -0,0 +1,14 @@
|
||||
export const EDITOR_DELETE = 'editorDelete';
|
||||
export const EDITOR_UPLOAD_POST_IMAGE = 'editorUploadImage';
|
||||
export const EDITOR_SAVE = 'editorSave';
|
||||
export const EDITOR_UPDATE = 'editorUpdate';
|
||||
|
||||
class EditorEvent {
|
||||
//--------------------------
|
||||
// methods
|
||||
//--------------------------
|
||||
//--------------------------
|
||||
// event handlers
|
||||
//--------------------------
|
||||
}
|
||||
export default new EditorEvent();
|
@ -0,0 +1,52 @@
|
||||
class EventEmitter {
|
||||
//--------------------------
|
||||
// constructor
|
||||
//--------------------------
|
||||
constructor() {
|
||||
this.listeners = new Map();
|
||||
}
|
||||
//--------------------------
|
||||
// methods
|
||||
//--------------------------
|
||||
addListener(label, callback) {
|
||||
this.listeners.has(label) || this.listeners.set(label, []);
|
||||
this.listeners.get(label).push(callback);
|
||||
}
|
||||
|
||||
removeListener(label, callback) {
|
||||
var isFunction = function(obj) {
|
||||
return typeof obj == 'function' || false;
|
||||
};
|
||||
|
||||
var listeners = this.listeners.get(label),
|
||||
index;
|
||||
|
||||
if (listeners && listeners.length) {
|
||||
index = listeners.reduce((i, listener, index) => {
|
||||
return isFunction(listener) && listener === callback ? (i = index) : i;
|
||||
}, -1);
|
||||
|
||||
if (index > -1) {
|
||||
listeners.splice(index, 1);
|
||||
this.listeners.set(label, listeners);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
emitEvent(label, ...args) {
|
||||
var listeners = this.listeners.get(label);
|
||||
if (listeners && listeners.length) {
|
||||
listeners.forEach(listener => {
|
||||
listener(...args);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//--------------------------
|
||||
// event handlers
|
||||
//--------------------------
|
||||
}
|
||||
export default EventEmitter;
|
Loading…
Reference in New Issue