Skip to content

Commit

Permalink
3850 - review fixes: move reportObserved() into conditions branch; ch…
Browse files Browse the repository at this point in the history
…ange strict inequality operator to strict equality
  • Loading branch information
inoyakaigor committed Apr 18, 2024
1 parent 7131add commit 6b93c8a
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions packages/mobx/src/types/observableset.ts
Expand Up @@ -244,9 +244,8 @@ export class ObservableSet<T = any> implements Set<T>, IInterceptable<ISetWillCh
}

intersection<U>(otherSet: ReadonlySetLike<U>): Set<T & U> {
this.atom_.reportObserved()

if (typeof otherSet.intersection !== "function") {
if (typeof otherSet.intersection === "function") {
this.atom_.reportObserved()
return otherSet.intersection(this.data_)
} else {
const dehancedSet = new Set(this)
Expand All @@ -255,9 +254,8 @@ export class ObservableSet<T = any> implements Set<T>, IInterceptable<ISetWillCh
}

union<U>(otherSet: ReadonlySetLike<U>): Set<T | U> {
this.atom_.reportObserved()

if (typeof otherSet.union !== "function") {
if (typeof otherSet.union === "function") {
this.atom_.reportObserved()
return otherSet.union(this.data_)
} else {
const dehancedSet = new Set(this)
Expand All @@ -266,9 +264,8 @@ export class ObservableSet<T = any> implements Set<T>, IInterceptable<ISetWillCh
}

difference<U>(otherSet: ReadonlySetLike<U>): Set<T> {
this.atom_.reportObserved()

if (typeof otherSet.difference !== "function") {
if (typeof otherSet.difference === "function") {
this.atom_.reportObserved()
return otherSet.difference(this.data_)
} else {
const dehancedSet = new Set(this)
Expand All @@ -277,9 +274,8 @@ export class ObservableSet<T = any> implements Set<T>, IInterceptable<ISetWillCh
}

symmetricDifference<U>(otherSet: ReadonlySetLike<U>): Set<T | U> {
this.atom_.reportObserved()

if (typeof otherSet.symmetricDifference !== "function") {
if (typeof otherSet.symmetricDifference === "function") {
this.atom_.reportObserved()
return otherSet.symmetricDifference(this.data_)
} else {
const dehancedSet = new Set(this)
Expand Down

0 comments on commit 6b93c8a

Please sign in to comment.