-
Notifications
You must be signed in to change notification settings - Fork 3k
Unsubscribe is slow when observers number > 10000 #5638
Copy link
Copy link
Closed
Description
Both of indexOf and splice are slow. Why not use a Set to store observers?
rxjs/src/internal/SubjectSubscription.ts
Lines 17 to 39 in 40b32d8
| unsubscribe() { | |
| if (this.closed) { | |
| return; | |
| } | |
| this.closed = true; | |
| const subject = this.subject; | |
| const observers = subject.observers; | |
| this.subject = null!; | |
| if (!observers || observers.length === 0 || subject.isStopped || subject.closed) { | |
| return; | |
| } | |
| const subscriberIndex = observers.indexOf(this.subscriber); | |
| if (subscriberIndex !== -1) { | |
| observers.splice(subscriberIndex, 1); | |
| } | |
| } | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels