@dxos/app-framework - v0.8.3
    Preparing search index...

    Function make

    • Creates a type-safe undo mapping.

      Type Parameters

      • Op extends Definition<any, any>
      • Inv extends Definition<any, any>

      Parameters

      Returns UndoMapping.UndoMapping<Op, Inv>

      // Static message
      const mapping = UndoMapping.make({
      operation: DeleteThread,
      inverse: RestoreThread,
      deriveContext: (input, output) => ({
      thread: output.thread,
      anchor: output.anchor,
      }),
      message: ['thread deleted label', { ns: '@dxos/plugin-thread' }],
      });

      // Dynamic message based on input/output
      const mapping = UndoMapping.make({
      operation: RemoveObjects,
      inverse: RestoreObjects,
      deriveContext: (_input, output) => output,
      message: (input, _output) =>
      input.objects.length === 1
      ? ['object deleted label', { ns: getTypename(input.objects[0]) }]
      : ['objects deleted label', { ns: '@dxos/plugin-space' }],
      });