Skip to content

Commit

Permalink
chore!: remove onceWriteDoc()
Browse files Browse the repository at this point in the history
Fixes #15, this is no longer needed by @mapeo/core,
since this is done outside of the indexer
  • Loading branch information
gmaclennan committed Oct 22, 2023
1 parent 2a63655 commit 05aa3fd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 172 deletions.
41 changes: 0 additions & 41 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ export class DbApi {
#docDefaults
#tableInfo

/** @type {Map<string, Set<IndexCallback<TDoc>>>} */
#listeners = new Map()

/**
* @param {import('better-sqlite3').Database} db
* @param {object} options
Expand Down Expand Up @@ -123,36 +120,6 @@ export class DbApi {
}
}
this.#writeDocSql.run(flattenedDoc)

const { versionId } = doc
if (this.#listeners.has(versionId)) {
process.nextTick(() => {
const set = this.#listeners.get(versionId)
if (set) {
for (const listener of set.values()) {
listener(doc)
}
this.#listeners.delete(versionId)
}
})
}
}
/**
* @param {string} versionId
* @param {IndexCallback<TDoc>} listener
*/
onceWriteDoc(versionId, listener) {
if (!this.#listeners.has(versionId)) {
this.#listeners.set(versionId, new Set())
}

const set = this.#listeners.get(versionId)
if (set && set.has(listener)) {
return
} else if (set) {
set.add(listener)
this.#listeners.set(versionId, set)
}
}
/**
* @param {string} docId
Expand Down Expand Up @@ -257,14 +224,6 @@ export default class SqliteIndexer {
isLinked(versionId) {
return !!this.#dbApi.getBacklink(versionId)
}

/**
* @param {string} versionId
* @param {IndexCallback<TDoc>} listener
*/
onceWriteDoc(versionId, listener) {
this.#dbApi.onceWriteDoc(versionId, listener)
}
}

/**
Expand Down
131 changes: 0 additions & 131 deletions test/index-callback.js

This file was deleted.

0 comments on commit 05aa3fd

Please sign in to comment.