| 13 | } |
| 14 | |
| 15 | export class ChildSet { |
| 16 | childParentRef: ParentReference |
| 17 | children: SplootNode[] |
| 18 | type: ChildSetType |
| 19 | minChildren: number |
| 20 | maxChildren: number |
| 21 | nodeCategory: NodeCategory |
| 22 | mutationObservers: ChildSetObserver[] |
| 23 | enableMutations: boolean |
| 24 | |
| 25 | constructor( |
| 26 | owner: SplootNode, |
| 27 | childSetId: string, |
| 28 | type: ChildSetType, |
| 29 | nodeCategory: NodeCategory, |
| 30 | minChildren: number, |
| 31 | maxChildren: number |
| 32 | ) { |
| 33 | this.children = [] |
| 34 | this.childParentRef = new ParentReference(owner, childSetId) |
| 35 | this.type = type |
| 36 | this.minChildren = minChildren |
| 37 | if (this.type === ChildSetType.Single) { |
| 38 | this.maxChildren = 1 |
| 39 | } else if (this.type === ChildSetType.Immutable) { |
| 40 | this.maxChildren = minChildren |
| 41 | } else { |
| 42 | this.maxChildren = maxChildren |
| 43 | } |
| 44 | |
| 45 | this.nodeCategory = nodeCategory |
| 46 | this.mutationObservers = [] |
| 47 | this.enableMutations = false |
| 48 | } |
| 49 | |
| 50 | getParentRef() { |
| 51 | return this.childParentRef |
| 52 | } |
| 53 | |
| 54 | getChildren() { |
| 55 | return this.children |
| 56 | } |
| 57 | |
| 58 | getNodeCategory() { |
| 59 | return this.nodeCategory |
| 60 | } |
| 61 | |
| 62 | fireMutation(mutation: ChildSetMutation) { |
| 63 | this.mutationObservers.forEach((observer: ChildSetObserver) => { |
| 64 | observer.handleChildSetMutation(mutation) |
| 65 | }) |
| 66 | globalMutationDispatcher.handleChildSetMutation(mutation) |
| 67 | } |
| 68 | |
| 69 | registerObserver(observer: ChildSetObserver) { |
| 70 | this.mutationObservers.push(observer) |
| 71 | } |
| 72 |
nothing calls this directly
no outgoing calls
no test coverage detected