api.serialize()
Description
Allows getting the current file structure as a plain arrayUsage
api.serialize (
id?: string
): void;
Parameters
id
- (optional) a path to files and folders
Returns an array with files and folders in the specified directory or all files and folders.
Example
<script>
import { getData, getDrive } from "./common/data";
import { Filemanager } from "wx-svelte-filemanager";
function init(api) {
console.log(api.getFile("/Code/Button.svelte"));
const serializedData = api.serialize();
console.log(serializedData);
// to show the serialized data
setTimeout(() => {
api.exec("provide-data", {
parent: "/",
data: serializedData,
});
}, 2000);
console.log(api.serialize("/Code"));
}
</script>
<Filemanager data="{getData()}" drive="{getDrive()}" {init} />
Related articles: