-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
(@)computed not updated #1546
Comments
Please create a sandbox demonstrating the issue
Op wo 16 mei 2018 02:24 schreef David Skx <[email protected]>:
… I've had really good experiences with computed-values. Now, I've come to a
case where the computed-value is simply not updated. Here the example:
@computedpublic get assignedGroups(): Option[] {
const { $: userJSON } = this.user;
const { $: allRoles } = this.roles;
if (userJSON && allRoles.length) {
const userRoles = allRoles.filter(r => {
for (const u of r.users || []) {
if (u.id === userJSON.id) {
return true;
}
}
return false;
});
return userRoles.map(role => ({
label: role.name,
value: role.id
}));
}
return [];
}
@computedpublic get hasAssignedGroups(): boolean {
console.log('hasAssignedGroups', this.assignedGroups);
return (
this.assignedGroups.some(group =>
this.companyRoles.$.some(cRole => cRole.id === group.value)
) === false
);
}
what's fine and updating is assignedGroups. Whenever the observables
referenced inside change, this value is re-calculated and all is good.
now, hasAssignedGroups has a dependency on assignedGroups, so
hasAssignedGroups should recalculate when assignedGroups changes. But it
does not. It just consoles out the first time and then nothing ever changes.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1546>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhGVsDa_aDgFetGUYmeQwnwyz-KBEks5ty3GwgaJpZM4UAd0i>
.
|
I went on creating an example on jsfiddle, there it all worked fine. That got me thinking and the problem was that |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[email protected]
I've had really good experiences with computed-values. Now, I've come to a case where the computed-value is simply not updated. Here the example:
what's fine and updating is
assignedGroups
. Whenever the observables referenced inside change, this value is re-calculated and all is good.now,
hasAssignedGroups
has a dependency onassignedGroups
, sohasAssignedGroups
should recalculate whenassignedGroups
changes. But it does not. It just consoles out the first time and then nothing ever changes.The text was updated successfully, but these errors were encountered: