-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
Computeds on encapsulated task's state not recomputing on change #424
Comments
@validkeys I think using computed properties might be the issue. Using normal getters seems to work: @task({ enqueue: true }) enqueueTask = {
reponse: null,
dfd: null,
respond() {
return this.dfd.resolve(true)
},
*perform() {
this.dfd = RSVP.defer()
let response = yield this.dfd.promise
this.response = response
return this
}
}
get lastTask() { return this.enqueueTask.last; }
get currentTask() {
const { lastTask } = this
console.log("computing")
return lastTask && lastTask.isRunning ? lastTask : null
} |
@maxfierke That certainly fixed it -- and confirmed my stupidity, I appreciate it! |
To be clear -- this is may still be a bug, but I don't remember if |
I think it is a bug with encapsulated tasks. Computeds do work on glimmer components although aren't always necessary. There's definitely still some issues with the non-ember objects with encapsulated tasks (for example, waitForProperty in the below example will throw an error "Cannot redefine property: response" ...,
response: null,
defer: null,
respond(answer) {
if (typeof answer !== 'boolean') {
throw new Error('respond only takes true/false as an argument')
}
this.response = answer
},
*perform(props = {}) {
this.setProperties(props)
yield waitForProperty(this, "response", v => !!v)
return this.response
} |
I may be experiencing the same issue with the |
Just ran into this today as we dropped IE11 and upgraded to ember-concurrency 2 (I know, we're a little behind). I was hoping to be able to just get onto e-c 2 to get the benefits and worry about refactoring our large encapsulated tasks later, but we have a lot of computed properties watching the encapsulated tasks' state, so changing all of those into getters (and the implications of that) makes that work a much bigger job. It's also a little tricky in combination with the |
I also got bitten by this bug. Transitioning from |
I added a failing test for the This failing test passes if I only export the While doing this, I found out that using import { dependentKeyCompat } from '@ember/object/compat';
// ...
@dependentKeyCompat
@lastValue('task')
value; So, I believe we have some options:
I guess version 2 would create be the most seamless migration path (as I think it is expected), but I also don't know how to implement it. |
re: the issues raised w/ This seems like it's working exactly as expected. However, we should have documented that As e-c 2.x task state is all If there's further discussion on |
I have an encapsulated task called "enqeueTask" (which I know are just plain objects now).
In the component that creates an instance of this encapsulated task I have a computed that returns the most recent task in the queue with "isRunning=true".
When that task completes, the computed property is not recomputing (even though the UI updates to show the task is complete). This was not a problem pre 2.0, so looking to find the 2.0 solution. What am I missing? Sorry if I'm being stupid!
I've created a Twiddle for reproduction here: https://ember-twiddle.com/5ce2f2282b79a2446cb61af2c5ee0e9c?openFiles=components.my-component%5C.js%2Ctemplates.components.my-component%5C.hbs
The text was updated successfully, but these errors were encountered: