fix: Make `View` methods bound to `ViewData` object
Use case: You want to scope logic and state into the view rather than somewhere in a module.
Problem:
The View class wraps the ViewData as a getter, meaning instead of calling the function on the object, it just returns the reference to the function within the object. This means the function looses the reference to the object as this.
- This is an alternative for https://github.com/nextcloud-libraries/nextcloud-files/pull/1067
Instead of making View a real class that can be extended, this just allows to use stateful ViewData.
Meaning function like getContents and loadChildView do not loose the this context, but can still work with it.
This is useful to have stateful views, e.g. the favorites view which needs to load children based on a state (nodes added / removed).
Bundle Report
Changes will increase total bundle size by 106 bytes :arrow_up:
| Bundle name | Size | Change |
|---|---|---|
| @nextcloud/files-esm | 117.42kB | 53 bytes :arrow_up: |
| @nextcloud/files-esm-cjs | 118.8kB | 53 bytes :arrow_up: |