-
Notifications
You must be signed in to change notification settings - Fork 22.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editorial review: Document FileSystemObserver #38270
base: main
Are you sure you want to change the base?
Conversation
Preview URLs (6 pages)Flaws (6)Note! 5 documents with no flaws that don't need to be listed. 🎉 URL:
External URLs (14)URL:
URL:
URL:
URL:
URL:
(comment last updated: 2025-02-25 11:20:06) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Left a bunch of suggestions.
files/en-us/web/api/filesystemobserver/filesystemobserver/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/filesystemobserver/filesystemobserver/index.md
Outdated
Show resolved
Hide resolved
…x.md Co-authored-by: Thomas Steiner <[email protected]>
Co-authored-by: Thomas Steiner <[email protected]>
Co-authored-by: Thomas Steiner <[email protected]>
@tomayac thanks for the review! I think I've answered everything. Let me know if you feel this needs anything else, or give me an LGTM if you are happy with it. |
files/en-us/web/api/filesystemobserver/filesystemobserver/index.md
Outdated
Show resolved
Hide resolved
#### `FileSystemChangeRecord` structure | ||
|
||
`FileSystemChangeRecord` objects have the following structure: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are really two ways of dealing with dictionaries:
- document them inline as anonymous objects (so under the
records
bullet above say something like "an array of objects contain details of all the observed changes. Each object has the following properties:" - document them in separate pages, like we do for example with https://developer.mozilla.org/en-US/docs/Web/API/RequestInit.
Because this is quite a complex object it might be worth going with (2) here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I've given it a go. My next commit now contains a new FileSystemChangeRecord
page, which is included in the sidebar and linked to from the appropriate places.
### Parameters | ||
|
||
- `callback` | ||
- : A user-defined callback function that will be called when the observer has observed a change in the file system entry it has been tasked to observe (via {{domxref("FileSystemObserver.observe()")}}). The callback function body can be specified to return and process file change observations in any way you want, however, it always includes the following two parameters: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- : A user-defined callback function that will be called when the observer has observed a change in the file system entry it has been tasked to observe (via {{domxref("FileSystemObserver.observe()")}}). The callback function body can be specified to return and process file change observations in any way you want, however, it always includes the following two parameters: | |
- : A user-defined callback function that will be called when the observer has observed a change in the file system entry it has been asked to observe (via {{domxref("FileSystemObserver.observe()")}}). The callback function will be passed following two parameters: |
Subjective I suppose but surely it's obvious that you can implement the callback however you like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I've implemented this change in my next commit, with a small tweak.
} | ||
``` | ||
|
||
or a {{domxref("FileSystemSyncAccessHandle")}} for the OPFS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As before this reads like you're duplicating the syntax description.
I would say, for example, something like:
Once a FileSystemObserver instance is available, you can start observing changes to a file system entry.
You can observe a file or a directory in the user-visible file system, for example by asking the user to select a file or directory using
window.showSaveFilePicker()
orwindow.showDirectoryPicker()
:(example)
You can also observe a file in the OPFS:
(example)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call; I've updated this as suggested
### Parameters | ||
|
||
- `handle` | ||
- : The handle of the file system entry representing the file or directory to observe. This can be a {{domxref("FileSystemFileHandle")}} or {{domxref("FileSystemDirectoryHandle")}} for the user-observable file system and the [Origin Private File System](/en-US/docs/Web/API/File_System_API/Origin_private_file_system) (OPFS), or a {{domxref("FileSystemSyncAccessHandle")}} for the OPFS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as before:
- : The handle of the file system entry representing the file or directory to observe. This can be a {{domxref("FileSystemFileHandle")}} or {{domxref("FileSystemDirectoryHandle")}} for the user-observable file system and the [Origin Private File System](/en-US/docs/Web/API/File_System_API/Origin_private_file_system) (OPFS), or a {{domxref("FileSystemSyncAccessHandle")}} for the OPFS. | |
- : The handle of the file system entry representing the file or directory to observe. | |
- For the user-observable file system, this can be a {{domxref("FileSystemFileHandle")}} or a {{domxref("FileSystemDirectoryHandle")}}. | |
- For the [Origin Private File System](/en-US/docs/Web/API/File_System_API/Origin_private_file_system) (OPFS), it can be or a a {{domxref("FileSystemFileHandle")}}, a {{domxref("FileSystemDirectoryHandle")}}, or a {{domxref("FileSystemSyncAccessHandle")}}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
|
||
### Observe a file or directory | ||
|
||
Assuming a `FileSystemObserver` instance is available, you can start observing changes to a file system entry by calling the `observe()` method on it, passing it the handle of the entry to observe. This can be a {{domxref("FileSystemFileHandle")}} or {{domxref("FileSystemDirectoryHandle")}} for the user-observable file system and the [Origin Private File System](/en-US/docs/Web/API/File_System_API/Origin_private_file_system) (OPFS): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As before, I think explaining the different use cases is more helpful in an example than duplicating the types you can pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated, same as the other page.
Co-authored-by: wbamberg <[email protected]>
Co-authored-by: wbamberg <[email protected]>
…x.md Co-authored-by: wbamberg <[email protected]>
…x.md Co-authored-by: wbamberg <[email protected]>
Co-authored-by: wbamberg <[email protected]>
Co-authored-by: wbamberg <[email protected]>
Co-authored-by: wbamberg <[email protected]>
Description
Chrome 133 supports the
FileSystemObserver
interface, which allows you to observe changes to the underlying file system via a standard observer mechanism.This PR adds documentation for the new functionality, which mainly consists of new reference pages for the new interface.
Note that the feature is currently non-standard (see whatwg/fs#165), although it should be added to the spec soon. I have currently documented it as such.
Motivation
Additional details
See the relevant ChromeStatus entry for data: https://chromestatus.com/feature/4622243656630272
Relevant blog post: https://developer.chrome.com/blog/file-system-observer#start_observing_a_file_or_directory
Related issues and pull requests
Related BCD: mdn/browser-compat-data#25986