Skip to content

Comments

fix: Make View methods bound to ViewData object#1068

Closed
susnux wants to merge 1 commit intomainfrom
fix/allow-stateful-view-data
Closed

fix: Make View methods bound to ViewData object#1068
susnux wants to merge 1 commit intomainfrom
fix/allow-stateful-view-data

Conversation

@susnux
Copy link
Contributor

@susnux susnux commented Sep 3, 2024

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.


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).

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`.

Signed-off-by: Ferdinand Thiessen <[email protected]>
@susnux susnux added status: needs info ❓ Further information is requested 3. to review 3️⃣ Waiting for reviews labels Sep 3, 2024
@susnux susnux requested review from Pytal and skjnldsv September 3, 2024 22:21
@codecov
Copy link

codecov bot commented Sep 3, 2024

Bundle Report

Changes will increase total bundle size by 106 bytes ⬆️

Bundle name Size Change
@nextcloud/files-esm 117.42kB 53 bytes ⬆️
@nextcloud/files-esm-cjs 118.8kB 53 bytes ⬆️

@skjnldsv skjnldsv added 2. developing 2️⃣ Work in progress and removed 3. to review 3️⃣ Waiting for reviews labels Dec 11, 2025
@skjnldsv skjnldsv marked this pull request as draft December 11, 2025 08:11
@susnux susnux closed this in #1417 Dec 11, 2025
@susnux susnux deleted the fix/allow-stateful-view-data branch December 21, 2025 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing 2️⃣ Work in progress status: needs info ❓ Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants