aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/SelectionManager.ts
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2020-04-07 13:46:15 -0700
committerSam Wilkins <samwilkins333@gmail.com>2020-04-07 13:46:15 -0700
commit52ad8b3874419a76e6953c3bd698d9e68a3158a6 (patch)
treea20156fa4453c817aa52d8d807dbc705066c5f6e /src/client/util/SelectionManager.ts
parentedd96f6d78ff066f0a14efefaa92a9710caff9bd (diff)
parent9ad73769dd2f3a7c6598041f123dfd5cb7ef05d5 (diff)
pulled
Diffstat (limited to 'src/client/util/SelectionManager.ts')
-rw-r--r--src/client/util/SelectionManager.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/client/util/SelectionManager.ts b/src/client/util/SelectionManager.ts
index 0e281e77e..6c386d684 100644
--- a/src/client/util/SelectionManager.ts
+++ b/src/client/util/SelectionManager.ts
@@ -54,12 +54,14 @@ export namespace SelectionManager {
export function SelectDoc(docView: DocumentView, ctrlPressed: boolean): void {
manager.SelectDoc(docView, ctrlPressed);
}
-
+ // computed functions, such as used in IsSelected generate errors if they're called outside of a
+ // reaction context. Specifying the context with 'outsideReaction' allows an efficiency feature
+ // to avoid unnecessary mobx invalidations when running inside a reaction.
export function IsSelected(doc: DocumentView, outsideReaction?: boolean): boolean {
return outsideReaction ?
- manager.SelectedDocuments.get(doc) ? true : false :
- computedFn(function isSelected(doc: DocumentView) {
+ manager.SelectedDocuments.get(doc) ? true : false : // get() accesses a hashtable -- setting anything in the hashtable generates a mobx invalidation for every get()
+ computedFn(function isSelected(doc: DocumentView) { // wraapping get() in a computedFn only generates mobx() invalidations when the return value of the function for the specific get parameters has changed
return manager.SelectedDocuments.get(doc) ? true : false;
})(doc);
}