mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 06:28:51 +00:00
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:
1 parent
0f8923058f
commit
feb9e8a5d3
8 files changed
+219
-136
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { Note, NotesEvents } from '../../../typings/notes';
|
||||
import { getSource } from '../utils/miscUtils';
|
||||
import NotesService from './notes.service';
|
||||
import { notesLogger } from './notes.utils';
|
||||
|
||||
onNet(NotesEvents.ADD_NOTE, (note: Note) => {
|
||||
const src = getSource();
|
||||
NotesService.handleAddNote(src, note).catch((e) =>
|
||||
notesLogger.error(`Error occured in add note event (${src}), Error: ${e.message}`),
|
||||
);
|
||||
});
|
||||
|
||||
onNet(NotesEvents.FETCH_ALL_NOTES, async (limit?: number) => {
|
||||
const src = getSource();
|
||||
NotesService.handleFetchNotes(src, limit).catch((e) =>
|
||||
notesLogger.error(`Error occured in fetch note event (${src}), Error: ${e.message}`),
|
||||
);
|
||||
});
|
||||
|
||||
onNet(NotesEvents.DELETE_NOTE, async (noteId: number) => {
|
||||
const src = getSource();
|
||||
NotesService.handleDeleteNote(src, noteId).catch((e) =>
|
||||
notesLogger.error(`Error occured in delete note event (${src}), Error: ${e.message}`),
|
||||
);
|
||||
});
|
||||
|
||||
onNet(NotesEvents.UPDATE_NOTE, async (note: Note) => {
|
||||
const src = getSource();
|
||||
NotesService.handleUpdateNote(src, note).catch((e) =>
|
||||
notesLogger.error(`Error occured in fetch note event (${src}), Error: ${e.message}`),
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user