Skip to content

Commit

Permalink
wip: disposed
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jan 28, 2025
1 parent e95cfec commit 3566712
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ export class BucketContentObserver implements Meteor.LiveQueryHandle {

private updateBlueprintIds = _.debounce(
Meteor.bindEnvironment(() => {
if (this.#disposed) return

const newBlueprintIds = _.uniq(this.#cache.ShowStyleSourceLayers.find({}).map((rd) => rd.blueprintId))

if (!equivalentArrays(newBlueprintIds, this.#blueprintIds)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export class RundownContentObserver {
this.#cache = cache
}

#disposed = false

static async create(rundownIds: RundownId[], cache: ContentCache): Promise<RundownContentObserver> {
logger.silly(`Creating RundownContentObserver for rundowns "${rundownIds.join(',')}"`)

Expand Down Expand Up @@ -261,6 +263,8 @@ export class RundownContentObserver {

private updateShowStyleBaseIds = _.debounce(
Meteor.bindEnvironment(() => {
if (this.#disposed) return

const newShowStyleBaseIds = _.uniq(this.#cache.Rundowns.find({}).map((rd) => rd.showStyleBaseId))

if (!equivalentArrays(newShowStyleBaseIds, this.#showStyleBaseIds)) {
Expand All @@ -277,6 +281,8 @@ export class RundownContentObserver {

private updateBlueprintIds = _.debounce(
Meteor.bindEnvironment(() => {
if (this.#disposed) return

const newBlueprintIds = _.uniq(this.#cache.ShowStyleSourceLayers.find({}).map((rd) => rd.blueprintId))

if (!equivalentArrays(newBlueprintIds, this.#blueprintIds)) {
Expand All @@ -294,6 +300,8 @@ export class RundownContentObserver {
}

public dispose = (): void => {
this.#disposed = true

this.#observers.forEach((observer) => observer.stop())
}
}

0 comments on commit 3566712

Please sign in to comment.