private void MutateWithLockThenRaiseEvents([NotNull] Func <DiagramEvent> diagramMutatorFunc) { DiagramEvent diagramEvent; lock (_diagramUpdateLockObject) { diagramEvent = diagramMutatorFunc.Invoke(); LatestDiagram = diagramEvent.NewDiagram; } DiagramChanged?.Invoke(diagramEvent); _diagramChangedEventStream.OnNext(diagramEvent); AfterDiagramChanged?.Invoke(diagramEvent); }
private void MutateWithLockThenRaiseEvents([NotNull] Action <IDiagramMutator> diagramMutatorFunc) { DiagramEvent diagramEvent; lock (_diagramUpdateLockObject) { var diagramMutator = CreateDiagramMutator(); diagramMutatorFunc.Invoke(diagramMutator); diagramEvent = diagramMutator.GetDiagramEvent(); LatestDiagram = diagramEvent.NewDiagram; } if (diagramEvent.IsEmpty) { return; } DiagramChanged?.Invoke(diagramEvent); _diagramChangedEventStream.OnNext(diagramEvent); AfterDiagramChanged?.Invoke(diagramEvent); }