# Deferring a transaction

**URL:** <https://discuss.prosemirror.net/t/deferring-a-transaction/4748>\
**Category:** Uncategorized\
**Created:** [July 12, 2022, 2:32pm UTC](https://discuss.prosemirror.net/t/deferring-a-transaction/4748 "2022-07-12T14:32:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![iainure](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/iainure/32/2637_2.png) [@iainure](https://discuss.prosemirror.net/u/iainure)\
**Post date:** [July 12, 2022, 2:32pm UTC](https://discuss.prosemirror.net/t/deferring-a-transaction/4748/1 "2022-07-12T14:32:22Z")

</div>

I’m using `filterTransaction` to identify transactions I wish to prevent, in my case when the user deletes certain strings. I’d like to defer these transactions, waiting for a user to confirm, and only then apply them.

What’s the recommended way to do this? Options I have considered so far:

- Storing the transaction in plugin state from within `filterTransaction`, and applying it in the PluginView
- Appending the transaction with it’s inverse, and reapplying it once the user has confirmed

Thanks!

---

<div class="post-metadata">

**Author:** ![colel](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/colel/32/3589_2.png) [@colel](https://discuss.prosemirror.net/u/colel)\
**Post date:** [July 14, 2022, 3:39pm UTC](https://discuss.prosemirror.net/t/deferring-a-transaction/4748/2 "2022-07-14T15:39:09Z")

</div>

I have had a lot of time playing with the APIs you’re thinking about. Without trying it myself, I am 80% confident that the first option you mentioned should work for you.

To expand on this, I’d filter out the transaction you want to be confirmed and store that transaction into a variable `trNeedingConfirmation` or whatever.

Then, when actually confirmed, you’d dispatch the `trNeedingConfirmation` onto the state, but with an added transaction meta like “confirmed transaction”, so you can be sure in the plugin, it doesn’t try to confirm it again.

---

<div class="post-metadata">

**Author:** ![moonrise-tk](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/moonrise-tk/32/1705_2.png) [@moonrise-tk](https://discuss.prosemirror.net/u/moonrise-tk)\
**Post date:** [July 14, 2022, 6:09pm UTC](https://discuss.prosemirror.net/t/deferring-a-transaction/4748/3 "2022-07-14T18:09:59Z")

</div>

You might also need to do some form of rebasing…to make sure the confirmed transaction going through is being applied on the most current doc.

---

<div class="post-metadata">

**Author:** ![iainure](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/iainure/32/2637_2.png) [@iainure](https://discuss.prosemirror.net/u/iainure)\
**Post date:** [July 29, 2022, 9:57am UTC](https://discuss.prosemirror.net/t/deferring-a-transaction/4748/4 "2022-07-29T09:57:43Z")

</div>

I did indeed end up with option 1. It’s working OK, but it’s a lot of code - perhaps there will be a more elegant way to do this in future

---

<div class="post-metadata">

**Author:** ![iainure](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/iainure/32/2637_2.png) [@iainure](https://discuss.prosemirror.net/u/iainure)\
**Post date:** [July 29, 2022, 9:59am UTC](https://discuss.prosemirror.net/t/deferring-a-transaction/4748/5 "2022-07-29T09:59:13Z")

</div>

I dealt with this by implementing a “pause” - the transaction filter stops all transactions (except my deferred ones) until my deferred transactions were complete. A bit hacky, I admit.
