diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-09-09 09:33:04 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-09-09 09:33:04 -0300 |
commit | 9109356037ce98af378765302841c957cc96b8d8 (patch) | |
tree | bb72dc3976d962e2ce81f5d32028c627f60a2f37 /src/data/things/thing.js | |
parent | a9b96deeca6b2dacb7fac309c47e7bc6289270e6 (diff) |
data: exitWithoutContribs utility
Diffstat (limited to 'src/data/things/thing.js')
-rw-r--r-- | src/data/things/thing.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/data/things/thing.js b/src/data/things/thing.js index 52f0b773..fe9000b4 100644 --- a/src/data/things/thing.js +++ b/src/data/things/thing.js @@ -436,6 +436,23 @@ export function withResolvedContribs({ ]); } +// Shorthand for exiting if the contribution list (usually a property's update +// value) resolves to empty - ensuring that the later computed results are only +// returned if these contributions are present. +export function exitWithoutContribs({ + contribs, + value = null, +}) { + return compositeFrom(`exitWithoutContribs`, [ + withResolvedContribs({from: contribs}), + exitWithoutDependency({ + dependency: '#resolvedContribs', + mode: 'empty', + value, + }), + ]); +} + // Resolves a reference by using the provided find function to match it // within the provided thingData dependency. This will early exit if the // data dependency is null, or, if notFoundMode is set to 'exit', if the find |