remirror/remirror

View on GitHub
packages/remirror__react-core/src/hooks/use-doc-changed.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import type { GetHandler } from '@remirror/core';
import { DocChangedExtension, DocChangedOptions } from '@remirror/core';

import { useExtensionEvent } from './use-extension-event';

/**
 * A hook for subscribing to transactions that change the document
 */
export function useDocChanged(
  handler: NonNullable<GetHandler<DocChangedOptions>['docChanged']>,
): void {
  useExtensionEvent(DocChangedExtension, 'docChanged', handler);
}