I have a parent object, with multiple child objects. Every child object is of the same type and has a "ChildMethod" that contains some child specific logic. If the ChildMethod is called on any child, i want to serialize the state of all children. I put that logic into the parent object. Also I implemented it with the observer pattern, the children being the subjects, and the parent the observer. It works fine so far. Now I need another method "CallAllChildMethods", that basically calls the ChildMethod on every child, yet I want to avoid multiple serializations, since it is necessary to do it only once.
The only solution I see at the moment is to unsubscribe to all subjectevents before calling CallAllChildMethods, then resubscribe again. That works but is a heavy design smell. Are there, from a design standpoint, cleaner ways to handle that case?