OverviewFilesCommitsIssuesDocsReleasesPeers

holepunchto-deps / @holepunchto / keet-editor / src / extensions / helpers / async-command.js

9 lines · javascript ref:
// async command workaround:
//  - Commands are made to be sync
//  - Calling a single command with an async fn it works but logs the error "Applying a mismatched transaction" (prosemirror makes the state/transaction stale during the async call)
//  - Pushing the command to the next tick solves the issue although most probably it won't work if you try to chain an async command with another command. For a single command call it seems to work fine.
//  - Related: https://github.com/ueberdosis/tiptap/discussions/4825
export function asyncCommand (fn) {
  Promise.resolve().then(fn)
}