fix some tests, implement event classes for types, and re-implement logging

This commit is contained in:
Kevin Jahns
2017-10-22 19:13:03 +02:00
parent c92f987496
commit 142a5ada60
3 changed files with 97 additions and 0 deletions

24
src/Transaction.js Normal file
View File

@@ -0,0 +1,24 @@
export default class Transaction {
constructor (y) {
this.y = y
// types added during transaction
this.newTypes = new Set()
// changed types (does not include new types)
// maps from type to parentSubs (item.parentSub = null for array elements)
this.changedTypes = new Map()
}
}
export function transactionTypeChanged (y, type, sub) {
if (type !== y && !type._deleted) {
const changedTypes = y._transaction.changedTypes
let subs = changedTypes.get(type)
if (subs === undefined) {
// create if it doesn't exist yet
subs = new Set()
changedTypes.set(type, subs)
}
subs.add(sub)
}
}