File size: 493 Bytes
cce8120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"use client";

import {useState} from "react";
import builder from "../services/builder/client";

export default function useVisualBuilder(){

const [loading,setLoading]=useState(false);

async function run(fn,...args){
setLoading(true);
try{
return await fn(...args);
}
finally{
setLoading(false);
}
}

return{
loading,
load:(...a)=>run(builder.load,...a),
save:(...a)=>run(builder.save,...a),
generate:(...a)=>run(builder.generate,...a),
exportProject:(...a)=>run(builder.export,...a)
};

}