Dynamically created computed property seems to be broken in 3.1
See original GitHub issueHello !
I’m using dynamically generated computed property, and it seems to not work anymore in 3.1.
Here is a code sample of what I’m doing :
setupNormalUser(currentUser) {
Ember.set(this, "projects",
Ember.computed("currentUser.projects.[]", "demoAccounts.@each.projects",
() => {
let projects = [].concat(currentUser.get("projects"))
const demoAccounts = this.get("demoAccounts.content")
if (Ember.isArray(demoAccounts)) {
demoAccounts.forEach(
(demoAccount) => projects = projects.concat(demoAccount.get("projects"))
)
}
return projects
}
)
)
Ember.set(this, "accounts",
Ember.computed("currentUser.accounts.[]", "projects.[]", function() {
const projects = currentUser.get("projects") || [];
return projects
.filter(project=>!Ember.isNone(project))
.map(project=>project.get("account.content"))
.concat( currentUser.get("accounts"))
.filter(a => !Ember.isNone(a)).uniq()
})
)
Ember.set(this, "assetLibraries",
Ember.computed("accounts.@each.assetLibraries", function() {
return currentUser.get("accounts").map(
(account) => account.get("assetLibraries").toArray()
).reduce(
(prev, cur) => prev.concat(cur), []
).uniq()
})
)
},
setupSuperAdmin(currentUser) {
this.set("projects", this.get("store").findAll("project"))
this.set("accounts", this.get("store").findAll("account"))
this.set("assetLibraries", this.get("store").findAll("assetLibrary"))
},
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Dynamic computed property name - vue.js
When using it in a method, you might need to check it's existence depending on the call sequence. computed: { element() { return...
Read more >XPath and XQuery Functions and Operators 3.1
As explained in XDM, document, element and processing-instruction nodes have a base-uri property which may be empty. The base-uri property for ...
Read more >Model validation in ASP.NET Core MVC and Razor Pages
Create an action method for JavaScript to call. The jQuery Validation remote method expects a JSON response: true means the input data is...
Read more >SystemVerilog 3.1a Language Reference Manual
Four subcommittees worked on various aspects of the SystemVerilog 3.1 ... class extension allows objects to be created and destroyed dynamically.
Read more >Developer Guide :: NVIDIA Deep Learning TensorRT ...
The physical partitions provide dedicated compute and memory slices with QoS ... 3.1.1. Creating a Network Definition. After the builder has been created, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m fairly sure my prior comment is correct, and this is a duplicate of https://github.com/emberjs/ember.js/issues/16427. Essentially doing this:
Is not a thing we actually support. The quick solution in your snippet above would be to move from
Ember.set
toEmber.defineProperty
(which works all the way back to Ember 1.x).Something like this...
Closing it, as it was a miss-use of the system.