@@ -15,6 +15,27 @@ import {isEPkg,
1515 * ChangeManager objects are retained in the corresponding EPkg
1616 * smartObject, as a convenient cataloging mechanism.
1717 *
18+ * **Auto Synchronization**:
19+ *
20+ * ChangeManager greatly simplifies the change process by
21+ * automatically applying the required synchronization to the:
22+ *
23+ * - graphical representation (i.e. the Konva state)
24+ * ... app logic focuses on SmartObject changes,
25+ * and ChangeManager auto syncs the visual graphics
26+ *
27+ * - SmartObject parentage
28+ * ... app logic merely changes a "focused" target object
29+ * and ChangeManager auto syncs it's parentage.
30+ * This is accomplished via SmartObject.trickleUpChange(),
31+ * propagating things like crc computations, and dynamic container size.
32+ *
33+ * - ChangeMonitor state (see ChangeMonitor Object below)
34+ * ... of course self's reflective ChangeMonitor state is auto synced.
35+ * This is accomplished through the syncMonitoredChange() method,
36+ * invoked at the appropriate places.
37+ *
38+ *
1839 * **API**:
1940 *
2041 * There are two distinct APIs you should be aware of (as in all
@@ -27,19 +48,23 @@ import {isEPkg,
2748 * + changeDispMode(dispMode): void - change the dispMode of self's PkgEntry (view/edit/animate)
2849 *
2950 * + syncMonitoredChange(): void - synchronize self's ChangeMonitor (store value),
30- * due to a change that has just been made to self's ePkg.
31- * ... as detected in CRC computations:
32- * - SmartObject.resetCrc(): void
33- * - SmartObject.resetBaseCrc(): void
51+ * due to a change that has just been made to self's ePkg
52+ * impacting items monitored by ChangeManger {dispMode, inSync, undoAvail, redoAvail},
53+ * for example:
54+ * * CRC computations (impacting: {inSync, undoAvail, redoAvail}):
55+ * - SmartObject.resetCrc(): void ... via SmartObject.trickleUpChange() driven by changeManager.applyChange()
56+ * - SmartObject.resetBaseCrc(): void ... via SmartPkg-constructor() and pkgPersist-savePkg()
57+ * * DispMode changes (impacting: {dispMode}):
58+ * - changeManager.changeDispMode(dispMode)
3459 *
3560 * + applyChange({changeFn, undoFn}): void - apply a change to our system, registering the change to our undo/redo stack,
36- * auto-syncing the parentage -and- our ChangeMonitor state .
61+ * auto-syncing required state (see "Auto Synchronization" above) .
3762 *
3863 * + applyUndo(): void - apply an "undo" operation to the PkgEntry on whose behalf we are managing,
39- * auto-syncing the parentage -and- our ChangeMonitor state .
64+ * auto-syncing required state (see "Auto Synchronization" above) .
4065 *
4166 * + applyRedo(): void - apply an "redo" operation to the PkgEntry on whose behalf we are managing,
42- * auto-syncing the parentage -and- our ChangeMonitor state .
67+ * auto-syncing required state (see "Auto Synchronization" above) .
4368 * ```
4469 *
4570 * 2. ChangeMonitor Object (the store value, accessible via
@@ -107,7 +132,7 @@ export default class ChangeManager {
107132 redoAvail : this . undoRedoMgr . isRedoAvail ( ) ,
108133 } ) ;
109134
110- // demark this object a svelte custom store
135+ // demark this object as a svelte custom store
111136 this . subscribe = this . baseStore . subscribe ;
112137 }
113138
@@ -172,8 +197,8 @@ export default class ChangeManager {
172197
173198 /**
174199 * Apply a change to our system, registering the change to our
175- * undo/redo stack, auto-syncing the parentage -and- our
176- * ChangeMonitor state .
200+ * undo/redo stack, auto-syncing required state (see "Auto
201+ * Synchronization" above) .
177202 *
178203 * - Changes are registered to the PkgEntry on whose behalf we
179204 * manage/monitor (i.e. this.ePkg). This must be consistent with
@@ -184,15 +209,10 @@ export default class ChangeManager {
184209 * `changeFn()` / `undoFn()` is as follows:
185210 *
186211 * ```js
187- * + changeFn(redoIndicator: <boolean> ): targetObj
188- * + undoFn(): targetObj
212+ * + changeFn(): targetObj
213+ * + undoFn(): targetObj
189214 * ```
190215 *
191- * - The `redoIndicator` param is an indicator as to whether the invocation
192- * is a **redo** operation, verses the initial execution.
193- * Typically a redo requires more work (for example syncing
194- * **both** the SmartObject and Konva realms).
195- *
196216 * - Both functions return the targetObj of the operation. This is
197217 * used to seed the synchronization of other parts of the model
198218 * ... via the `SmartModel.trickleUpChange()` method.
@@ -206,11 +226,9 @@ export default class ChangeManager {
206226 * active object.
207227 *
208228 * - Also, these change functions should only be concerned with the
209- * modification of a given low-level object. ChangeManager will
210- * orchestrate additional detail to insure conformity. For
211- * example, the service will issue the `targetObj.trickleUpChange()`
212- * which syncs the change to it parentage (synchronizing size and
213- * crc, etc.).
229+ * modification of a given low-level SmartObject. ChangeManager
230+ * will orchestrate additional detail to insure conformity (see
231+ * "Auto Synchronization" above).
214232 *
215233 * **Please Note** this service uses named parameters.
216234 *
@@ -239,34 +257,28 @@ export default class ChangeManager {
239257 this . undoRedoMgr . registerOp ( undoFn , changeFn ) ;
240258
241259 // apply the initial change
242- // NOTE: The change process auto-syncs our parentage -and- our ChangeMonitor state
243- // (via the trickleUpChange() mechanism)
244- applyChange ( check , this . ePkg , changeFn , false /*NOT a redo (rather our initial change)*/ ) ;
260+ applyChange ( check , this . ePkg , changeFn ) ;
245261 }
246262
247263
248264 /**
249265 * Apply an "undo" operation to the PkgEntry on whose behalf we are
250- * managing, auto-syncing the parentage -and- our ChangeMonitor
251- * state .
266+ * managing, auto-syncing required state (see "Auto Synchronization"
267+ * above) .
252268 */
253269 applyUndo ( ) {
254270 // simply propagate request into our undoRedoMgr
255- // NOTE: This process auto-syncs our parentage -and- our ChangeMonitor state
256- // (via the trickleUpChange() mechanism)
257271 this . undoRedoMgr . applyUndo ( ) ;
258272 }
259273
260274
261275 /**
262276 * Apply an "redo" operation to the PkgEntry on whose behalf we are
263- * managing, auto-syncing the parentage -and- our ChangeMonitor
264- * state .
277+ * managing, auto-syncing required state (see "Auto Synchronization"
278+ * above) .
265279 */
266280 applyRedo ( ) {
267281 // simply propagate request into our undoRedoMgr
268- // NOTE: This process auto-syncs our parentage -and- our ChangeMonitor state
269- // (via the trickleUpChange() mechanism)
270282 this . undoRedoMgr . applyRedo ( ) ;
271283 }
272284
0 commit comments