diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-04-03 13:16:16 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-04-03 13:44:00 -0300 |
commit | 0792908781a1956cd44038498bbd68f2bfdb8396 (patch) | |
tree | d9a9a62a4e3f81f8b6436eb4ef31b873a9df88e5 /src/data/composite/things/flash | |
parent | 01fca1864f58067ec95590700b5dead24fd2dc73 (diff) |
data: withUniqueReferencingThing
Diffstat (limited to 'src/data/composite/things/flash')
-rw-r--r-- | src/data/composite/things/flash/withFlashAct.js | 48 |
1 files changed, 6 insertions, 42 deletions
diff --git a/src/data/composite/things/flash/withFlashAct.js b/src/data/composite/things/flash/withFlashAct.js index 2c985fe0..652b8bfb 100644 --- a/src/data/composite/things/flash/withFlashAct.js +++ b/src/data/composite/things/flash/withFlashAct.js @@ -1,15 +1,10 @@ // Gets the flash's act. This will early exit if flashActData is missing. // 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, raiseOutputWithoutDependency} - from '#composite/control-flow'; -import {withPropertyFromList} from '#composite/data'; +import {withUniqueReferencingThing} from '#composite/wiki-data'; export default templateCompositeFrom({ annotation: `withFlashAct`, @@ -17,42 +12,11 @@ export default templateCompositeFrom({ outputs: ['#flashAct'], steps: () => [ - exitWithoutDependency({ - dependency: 'flashActData', - mode: input.value('null'), + withUniqueReferencingThing({ + data: 'flashActData', + list: input.value('flashes'), + }).outputs({ + ['#uniqueReferencingThing']: '#flashAct', }), - - withPropertyFromList({ - list: 'flashActData', - property: input.value('flashes'), - }), - - { - dependencies: [input.myself(), '#flashActData.flashes'], - compute: (continuation, { - [input.myself()]: track, - ['#flashActData.flashes']: flashLists, - }) => continuation({ - ['#flashActIndex']: - flashLists.findIndex(flashes => flashes.includes(track)), - }), - }, - - raiseOutputWithoutDependency({ - dependency: '#flashActIndex', - mode: input.value('index'), - output: input.value({'#album': null}), - }), - - { - dependencies: ['flashActData', '#flashActIndex'], - compute: (continuation, { - ['flashActData']: flashActData, - ['#flashActIndex']: flashActIndex, - }) => continuation.raiseOutput({ - ['#flashAct']: - flashActData[flashActIndex], - }), - }, ], }); |