perf: remove callbackToObserve

This commit is contained in:
molvqingtai 2024-09-26 08:15:42 +08:00
parent 437c234f8a
commit 415b9f507e
3 changed files with 2 additions and 21 deletions

View file

@ -1,10 +1,10 @@
import { Remesh } from 'remesh' 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 { NormalMessage, type MessageUser } from './MessageList'
import { PeerRoomExtern } from '@/domain/externs/PeerRoom' import { PeerRoomExtern } from '@/domain/externs/PeerRoom'
import MessageListDomain, { MessageType } from '@/domain/MessageList' import MessageListDomain, { MessageType } from '@/domain/MessageList'
import UserInfoDomain from '@/domain/UserInfo' import UserInfoDomain from '@/domain/UserInfo'
import { fromEventPattern, desert, upsert } from '@/utils' import { desert, upsert } from '@/utils'
import { nanoid } from 'nanoid' import { nanoid } from 'nanoid'
import StatusModule from '@/domain/modules/Status' import StatusModule from '@/domain/modules/Status'

View file

@ -1,18 +0,0 @@
import { Observable } from 'rxjs'
export type Subscribe<T> = (callback: (event: T) => void) => void
const fromEventPattern = <T>(subscribe: Subscribe<T>, unsubscribe?: () => void) => {
return new Observable<T>((subscriber) => {
subscribe((event: T) => {
subscriber.next(event)
})
return () => {
unsubscribe?.()
subscriber.complete()
}
})
}
export default fromEventPattern

View file

@ -5,7 +5,6 @@ export { default as getSiteInfo } from './getSiteInfo'
export { default as compressImage } from './compressImage' export { default as compressImage } from './compressImage'
export { default as isNullish } from './isNullish' export { default as isNullish } from './isNullish'
export { default as checkSystemDarkMode } from './checkSystemDarkMode' export { default as checkSystemDarkMode } from './checkSystemDarkMode'
export { default as fromEventPattern } from './fromEventPattern'
export { default as stringToHex } from './stringToHex' export { default as stringToHex } from './stringToHex'
export { default as debounce } from './debounce' export { default as debounce } from './debounce'
export { default as throttle } from './throttle' export { default as throttle } from './throttle'