watchPublicFolder()v4.0.154
监视 public 目录 的变化,并在文件被添加、删除或修改时调用回调函数。
🌐 Watches for changes in the public directory and calls a callback function when a file is added, removed or modified.
note
此功能仅在 Remotion Studio 环境中可用。在播放器中,事件永远不会触发。
示例
🌐 Example
example.tsximport {StaticFile ,watchPublicFolder } from "@remotion/studio"; // Watch for changes in a specific static file const {cancel } =watchPublicFolder ((newFiles :StaticFile []) => {console .log ("The public folder now contains:",newFiles ); }); // To stop watching for changes, call the cancel functioncancel ();
参数
🌐 Arguments
接受一个参数并返回一个可以用来 cancel 事件监听器的函数。
🌐 Takes one argument and returns a function that can be used to cancel the event listener.
callback
当目录被修改时将调用的回调函数。作为参数,将传入一个 StaticFile 数组。
🌐 A callback function that will be called when the directory is modified. As an argument, an array of StaticFile's is passed.
另请参阅
🌐 See also