refactor(server/notes): Implement singleton architecture

Also trying something out with the response structure on the server to cut down on redundant calls.
This commit is contained in:
Taso committed 2021-04-19 14:14:25 -04:00
1 parent 0f8923058f
commit feb9e8a5d3
8 files changed
+219 -136

No files matched your search

+11 -4
View File
@@ -1,3 +1,5 @@
import { IAlertProps } from './alerts';
export type AlertCategory =
| 'NOTES_ADD_SUCCESS'
| 'NOTES_ADD_FAILED'
@@ -17,10 +19,6 @@ export interface Note {
content: string;
}
export interface NoteId {
id: number;
}
export enum NotesEvents {
ADD_NOTE = 'npwd:addNote',
FETCH_ALL_NOTES = 'npwd:fetchAllNotes',
@@ -33,4 +31,13 @@ export enum NotesEvents {
UPDATE_NOTE_FAILURE = 'npwd:updateNoteFailure',
ACTION_RESULT = 'npwd:notesActionResult',
SEND_ALERT = 'npwd:notesSetAlert',
SERVER_RESP = 'npwd:notesServerResp',
}
export interface NoteServerResponse<T = unknown> {
alert?: IAlertProps;
action: 'SEND' | 'UPDATE' | 'DELETE' | 'ADD';
suceeded: boolean;
refetch?: boolean;
data?: T;
}