You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Go, generally, interfaces are small and focused, as well as defined where they're being used. This also helps in testing, where we can define smaller focused interfaces which only mock methods that are used by the test, rather than a large interface where everything needs to be mocked even if majority of the methods aren't being used by the test.
The api package was useful when we required the concrete types to comply with the interface since we were returning the interfaces to the goja layer directly. E.g.:
// Ensure Browser implements the EventEmitter and Browser interfaces.var (
_EventEmitter=&Browser{}
_ api.Browser=&Browser{}
)
Now that we're working with the mapping layer which explicitly maps the implementation to a goja type, this api compliance requirement is no longer required.
When working on recent investigative issues, we've found that this interface api compliance has become a hinderance.
This issue is too explore whether we can remove the api package and what the consequences of that would be. Something to consider are:
Is is straight forward to find and replace the interface type with the concrete type?
Feature Description
In Go, generally, interfaces are small and focused, as well as defined where they're being used. This also helps in testing, where we can define smaller focused interfaces which only mock methods that are used by the test, rather than a large interface where everything needs to be mocked even if majority of the methods aren't being used by the test.
The
api
package was useful when we required the concrete types to comply with the interface since we were returning the interfaces to the goja layer directly. E.g.:Now that we're working with the mapping layer which explicitly maps the implementation to a goja type, this api compliance requirement is no longer required.
When working on recent investigative issues, we've found that this interface api compliance has become a hinderance.
This issue is too explore whether we can remove the
api
package and what the consequences of that would be. Something to consider are:POC
https://github.com/grafana/xk6-browser/commits/refactor/api-package-poc
Primary tasks
#1055: Remove the
api
package#1057: Refactor the
common
API types to concreteAlready existing or connected issues / PRs (optional)
Related issues:
The text was updated successfully, but these errors were encountered: