UNPKG

baked-recipe-admin

Version:

Baked is an opinionated framework for .NET in backend and Nuxt in frontend. This is a recipe package that brings together all the components one needs for an Admin UI.

27 lines (22 loc) 417 B
import { E_CANCELED } from "async-mutex"; export default function() { async function run(callback) { const mutex = useNuxtApp().$mutex; try { await mutex.acquire(); await callback(); } catch (e) { if(e !== E_CANCELED) { mutex.cancel(); } throw e; } finally { if(mutex.isLocked()) { mutex.release(); } } } return { run }; }