At first, BFS used callbacks in the constructor. As that was odd behavior, backend creation was changed to be done with the static Create method. Now that BFS uses promises internally, it would be better to use a more straightforward approach using a public constructor:
This allows users to use backends without a callback:
backend:
async op() {
await this.whenReady();
...
}
user code (remember this is through the compatibility layer):
configure({ fs: 'ExampleAsyncBackend' }); // note that await is not used.
const fs = BFSRequire('fs');
fs.op(() => {
// no waiting for the FS to be ready!
});
At first, BFS used callbacks in the constructor. As that was odd behavior, backend creation was changed to be done with the static
Create
method. Now that BFS uses promises internally, it would be better to use a more straightforward approach using a public constructor:This allows users to use backends without a callback:
backend:
user code (remember this is through the compatibility layer):