mirror of https://codeberg.org/pzp/pzp-goals.git
rename listen() to watch()
This commit is contained in:
parent
d9680acd27
commit
49c4e1b280
|
@ -151,7 +151,7 @@ function initGoals(peer, config) {
|
|||
|
||||
// State:
|
||||
const goals = /** @type {Map<string, Goal>} */ (new Map())
|
||||
const listen = Obz()
|
||||
const watch = Obz()
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
@ -196,7 +196,7 @@ function initGoals(peer, config) {
|
|||
function set(tangleID, goalDSL) {
|
||||
const goal = new GoalImpl(tangleID, goalDSL)
|
||||
goals.set(tangleID, goal)
|
||||
listen.set(goal)
|
||||
watch.set(goal)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -296,7 +296,7 @@ function initGoals(peer, config) {
|
|||
get,
|
||||
getMsgPurpose,
|
||||
list,
|
||||
listen,
|
||||
watch,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ const { isMapIterator } = require('node:util/types')
|
|||
const p = require('node:util').promisify
|
||||
const { createPeer } = require('./util')
|
||||
|
||||
test('set, getByID, list, listen', async (t) => {
|
||||
test('set, getByID, list, watch', async (t) => {
|
||||
const alice = createPeer({ name: 'alice' })
|
||||
|
||||
await alice.db.loaded()
|
||||
|
@ -14,16 +14,16 @@ test('set, getByID, list, listen', async (t) => {
|
|||
})
|
||||
const aliceAccountRoot = alice.db.getRecord(aliceID)
|
||||
|
||||
const listened = []
|
||||
const stopListening = alice.goals.listen((goal) => {
|
||||
listened.push(goal)
|
||||
const watched = []
|
||||
const stopListening = alice.goals.watch((goal) => {
|
||||
watched.push(goal)
|
||||
})
|
||||
|
||||
{
|
||||
assert.strictEqual(listened.length, 0, 'listened goals is empty')
|
||||
assert.strictEqual(watched.length, 0, 'watched goals is empty')
|
||||
alice.goals.set(aliceID, 'newest-5')
|
||||
assert('set goal done')
|
||||
assert.strictEqual(listened.length, 1, 'listened goals has one')
|
||||
assert.strictEqual(watched.length, 1, 'watched goals has one')
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ test('set, getByID, list, listen', async (t) => {
|
|||
assert.strictEqual(goal.id, aliceID, 'listed goal id is correct')
|
||||
}
|
||||
|
||||
assert.strictEqual(listened.length, 1, 'total listened goals was one')
|
||||
assert.strictEqual(watched.length, 1, 'total watched goals was one')
|
||||
|
||||
assert.strictEqual(
|
||||
typeof stopListening,
|
||||
|
|
Loading…
Reference in New Issue