From 415b9f507ee9268e11d1e98d8dcb5e22b6f594d3 Mon Sep 17 00:00:00 2001 From: molvqingtai Date: Thu, 26 Sep 2024 08:15:42 +0800 Subject: [PATCH] perf: remove callbackToObserve --- src/domain/Room.ts | 4 ++-- src/utils/callbackToObservable.ts | 18 ------------------ src/utils/index.ts | 1 - 3 files changed, 2 insertions(+), 21 deletions(-) delete mode 100644 src/utils/callbackToObservable.ts diff --git a/src/domain/Room.ts b/src/domain/Room.ts index 6821679..c10754a 100644 --- a/src/domain/Room.ts +++ b/src/domain/Room.ts @@ -1,10 +1,10 @@ import { Remesh } from 'remesh' -import { map, merge, of, EMPTY, mergeMap, fromEvent, Observable, tap } from 'rxjs' +import { map, merge, of, EMPTY, mergeMap, fromEvent, Observable, tap, fromEventPattern } from 'rxjs' import { NormalMessage, type MessageUser } from './MessageList' import { PeerRoomExtern } from '@/domain/externs/PeerRoom' import MessageListDomain, { MessageType } from '@/domain/MessageList' import UserInfoDomain from '@/domain/UserInfo' -import { fromEventPattern, desert, upsert } from '@/utils' +import { desert, upsert } from '@/utils' import { nanoid } from 'nanoid' import StatusModule from '@/domain/modules/Status' diff --git a/src/utils/callbackToObservable.ts b/src/utils/callbackToObservable.ts deleted file mode 100644 index 64662b0..0000000 --- a/src/utils/callbackToObservable.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Observable } from 'rxjs' - -export type Subscribe = (callback: (event: T) => void) => void - -const fromEventPattern = (subscribe: Subscribe, unsubscribe?: () => void) => { - return new Observable((subscriber) => { - subscribe((event: T) => { - subscriber.next(event) - }) - - return () => { - unsubscribe?.() - subscriber.complete() - } - }) -} - -export default fromEventPattern diff --git a/src/utils/index.ts b/src/utils/index.ts index 8f55a3f..b950821 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -5,7 +5,6 @@ export { default as getSiteInfo } from './getSiteInfo' export { default as compressImage } from './compressImage' export { default as isNullish } from './isNullish' export { default as checkSystemDarkMode } from './checkSystemDarkMode' -export { default as fromEventPattern } from './fromEventPattern' export { default as stringToHex } from './stringToHex' export { default as debounce } from './debounce' export { default as throttle } from './throttle'