diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-04-03 12:58:49 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-04-03 13:44:00 -0300 |
commit | 01fca1864f58067ec95590700b5dead24fd2dc73 (patch) | |
tree | 1dd214b38f1692b6c6122c8244a328b595f91628 /src/data/composite/things/flash | |
parent | c730fce11ed3cd57cca6b5290bb83adeb6100dde (diff) |
data: simplify withAlbum, withFlashAct, remove notFoundMode
Diffstat (limited to 'src/data/composite/things/flash')
-rw-r--r-- | src/data/composite/things/flash/withFlashAct.js | 62 |
1 files changed, 6 insertions, 56 deletions
diff --git a/src/data/composite/things/flash/withFlashAct.js b/src/data/composite/things/flash/withFlashAct.js index ada2dcfe..2c985fe0 100644 --- a/src/data/composite/things/flash/withFlashAct.js +++ b/src/data/composite/things/flash/withFlashAct.js @@ -1,60 +1,27 @@ // Gets the flash's act. This will early exit if flashActData is missing. -// By default, if there's no flash whose list of flashes includes this flash, -// the output dependency will be null; set {notFoundMode: 'exit'} to early -// exit instead. +// If there's no flash whose list of flashes includes this flash, the output +// dependency will be null. // // This step models with Flash.withAlbum. import {input, templateCompositeFrom} from '#composite'; import {is} from '#validators'; -import {exitWithoutDependency, withResultOfAvailabilityCheck} +import {exitWithoutDependency, raiseOutputWithoutDependency} from '#composite/control-flow'; import {withPropertyFromList} from '#composite/data'; export default templateCompositeFrom({ annotation: `withFlashAct`, - inputs: { - notFoundMode: input({ - validate: is('exit', 'null'), - defaultValue: 'null', - }), - }, - outputs: ['#flashAct'], steps: () => [ - // null flashActData is always an early exit. - exitWithoutDependency({ dependency: 'flashActData', mode: input.value('null'), }), - // empty flashActData conditionally exits early or outputs null. - - withResultOfAvailabilityCheck({ - from: 'flashActData', - mode: input.value('empty'), - }).outputs({ - '#availability': '#flashActDataAvailability', - }), - - { - dependencies: [input('notFoundMode'), '#flashActDataAvailability'], - compute(continuation, { - [input('notFoundMode')]: notFoundMode, - ['#flashActDataAvailability']: flashActDataIsAvailable, - }) { - if (flashActDataIsAvailable) return continuation(); - switch (notFoundMode) { - case 'exit': return continuation.exit(null); - case 'null': return continuation.raiseOutput({'#flashAct': null}); - } - }, - }, - withPropertyFromList({ list: 'flashActData', property: input.value('flashes'), @@ -71,30 +38,13 @@ export default templateCompositeFrom({ }), }, - // album not found conditionally exits or outputs null. - - withResultOfAvailabilityCheck({ - from: '#flashActIndex', + raiseOutputWithoutDependency({ + dependency: '#flashActIndex', mode: input.value('index'), - }).outputs({ - '#availability': '#flashActAvailability', + output: input.value({'#album': null}), }), { - dependencies: [input('notFoundMode'), '#flashActAvailability'], - compute(continuation, { - [input('notFoundMode')]: notFoundMode, - ['#flashActAvailability']: flashActIsAvailable, - }) { - if (flashActIsAvailable) return continuation(); - switch (notFoundMode) { - case 'exit': return continuation.exit(null); - case 'null': return continuation.raiseOutput({'#flashAct': null}); - } - }, - }, - - { dependencies: ['flashActData', '#flashActIndex'], compute: (continuation, { ['flashActData']: flashActData, |