Reintent

@reintent/lib/orphans

Decisions no evaluation reads any more: the entity they were about is gone (a reprogramming took it away, a block was deleted).

Reported by key, never dropped: the host decides.

Functions

orphans()

function orphans(layers, results): string[];

Defined in: packages/lib/src/orphans.ts

Parameters

ParameterType
layersLayers
resultsreadonly Realization[]

Returns

string[]

Example

import { choices, createIntent, host, useChoose } from '@reintent/core';
import { orphans } from '@reintent/lib/orphans';

const Reply = (p: { id: string }) =>
  host('reply', {
    tone: useChoose(choices('formal', 'warm'), {
      of: p.id,
      name: 'tone',
      defaultValue: 'warm',
    }),
  });

const intent = createIntent({
  program: (
    <>
      <Reply id="r1" />
      <Reply id="r2" />
    </>
  ),
});
intent.decide({ of: 'r2', name: 'tone' }, 'formal');
intent.setProgram(<Reply id="r1" />); // r2 is deleted
console.log(orphans(intent.layers, [intent.realize()])); // → [ 'r2#tone' ]

Last updated on

Edit on GitHub