Progress bar? #242
-
Hello, I'm working on a project with a unified processor in the browser (in a Tauri app). Some plugins can take quite a while, such as base64-encoding and inlining external assets, and others. So I am thinking about implementing some kind of progress bar to entertain my waiting users... I haven't found a project on GitHub that tries to accomplish this. Any advice on how I should approach it? My initial thought is some something that adds a logger plugin after each "real" plugin and increments (code not checked but hopefully you get the idea): export function createProcessorWithLogs(
plugins: PluggableList,
onUpdate: UpdateHander
) {
let counter = 0;
const logger = createLogger(onUpdate, counter);
const plugginsWithLogs = plugins.reduce((acc: PluggableList, plugin) => {
acc.push(plugin, logger);
return acc;
}, []);
return {
processor: unified.use(plugginsWithLogs);
total: plugins.length
}
}
function createLogger(onUpdate: UpdateHander, counter: number) {
return () => {
onUpdate(counter++);
};
} I'm aiming for a data shape like this:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Welcome @dmca-glasgow! Taking a step back, before going too far down the rabbit hole consider two questions.
If the answer to one or both of these is "no", a progress bar probably doesn't make sense. If you do choose to go down the progress bar route.
|
Beta Was this translation helpful? Give feedback.
Welcome @dmca-glasgow!
Taking a step back, before going too far down the rabbit hole consider two questions.
If the answer to one or both of these is "no", a progress bar probably doesn't make sense.
And you may want to consider investing time in a nicely animated loader or spinner instead.
If you do choose to go down the progress bar route.
Some considerations: