We expose two APIs in devtools to check for watcher support: - hasTargetWatcherSupport - hasResourceWatcherSupport https://searchfox.org/mozilla-central/search?q=has%28Resource%7CTarget%29WatcherSupport&path=&case=true®exp=true They both rely on the availability of a WatcherFront and then check traits on this watcher front. But hasTargetWatcherSupport is sometimes used to check traits which are not related at all to a target type: eg https://searchfox.org/mozilla-central/rev/185ab5e4f4e01341e009cd4633d1275ffe4d4c8b/devtools/shared/commands/target-configuration/target-configuration-command.js#38-40 ```javascript return this._commands.targetCommand.hasTargetWatcherSupport( "target-configuration" ); ``` We could replace both APIs with a single API with a clear signature: ``` /** * Check if the watcher is supported and additionally check for specific support of a * resourceType, targetType or custom trait. * * @param {Object} options * @param {String} options.resourceType * @param {String} options.targetType * @param {String} options.trait * @return {Boolean} true if the watcher is supported */ hasWatcherSupport({ resourceType, targetType, trait }) { /* ... */ } ```
Bug 1709292 Comment 0 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
We expose two APIs in devtools to check for watcher support: - hasTargetWatcherSupport - hasResourceWatcherSupport https://searchfox.org/mozilla-central/search?q=has%28Resource%7CTarget%29WatcherSupport&path=&case=true®exp=true They both rely on the availability of a WatcherFront and then check traits on this watcher front. But hasTargetWatcherSupport is sometimes used to check traits which are not related at all to a target type: eg https://searchfox.org/mozilla-central/rev/185ab5e4f4e01341e009cd4633d1275ffe4d4c8b/devtools/shared/commands/target-configuration/target-configuration-command.js#38-40 ```javascript return this._commands.targetCommand.hasTargetWatcherSupport( "target-configuration" ); ``` We could replace both APIs with a single API with a clear signature: ```javascript /** * Check if the watcher is supported and additionally check for specific support of a * resourceType, targetType or custom trait. * * @param {Object} options * @param {String} options.resourceType * @param {String} options.targetType * @param {String} options.trait * @return {Boolean} true if the watcher is supported */ hasWatcherSupport({ resourceType, targetType, trait }) { /* ... */ } ```