Skip to content
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

Shouldn't Aurelia.enhance resolve at some point? #480

Closed
tkhyn opened this issue Jul 22, 2016 · 5 comments · Fixed by #483
Closed

Shouldn't Aurelia.enhance resolve at some point? #480

tkhyn opened this issue Jul 22, 2016 · 5 comments · Fixed by #483
Assignees
Labels

Comments

@tkhyn
Copy link
Contributor

tkhyn commented Jul 22, 2016

Not sure if it's a bug, if it's intentional or if there was no other option.

From what I understand from the source code, the Promise returned by Aurelia.enhance never resolves.

As a consequence, there is no way to execute something only when the enhancement is completed.

I'm asking that because I'm trying to test a relatively complex component (using a slightly altered version of aurelia-testing but that works similarly, calling aurelia.enhance the same way), and the component is not rendered when the actual test starts (I said it was a relatively complex one!). I can't await the enhancement as it never resolves, so the only option for now is to use an appropriate timeout, which is not ideal.

Would there be a way to make this promise resolve at some point, or would the fact that all the gears it puts in motion behind the scenes prevent this?

Thanks in advance

@EisenbergEffect
Copy link
Contributor

It looks like a bug, this line: https://github.com/aurelia/framework/blob/master/src/aurelia.js#L110 should resolve this instead of return it. Would you be willing to submit a PR to fix that?

@tkhyn
Copy link
Contributor Author

tkhyn commented Jul 22, 2016

Yes, that would make the promise resolve ... but it does not solve the issue as there is no guarantee that when the returned promise resolves, the engine.enhance(...) and this.root.attached() have been completed as they are triggering async actions (and then a related issue would be that they do not return promises themselves).

That's what I was meaning when I was mentioning the 'gears it puts in motion behind the scenes'. Making the promise resolve is easy enough, making it resolve only after engine.enhance(...) and this.root.attached() may be a little tricky.

@tkhyn
Copy link
Contributor Author

tkhyn commented Jul 22, 2016

I took some time to look at the 'gears', and it seems that what would be needed to achieve the above mentioned behavior would involve a possibly important refactor of aurelia/templating to make every bind, attached, detached, unbind method return a Promise made of all the promises returned by the nested calls to other bind, etc. methods on children controllers, view-models, etc. I'm unsure if this is what you'd want, and I'm even less sure my understanding of Aurelia's internals is good enough to assume this would work without creating other problems ...

@EisenbergEffect
Copy link
Contributor

The component lifecycle methods are always synchronous. Changing that would ruin the framework probably ;)

@tkhyn
Copy link
Contributor Author

tkhyn commented Jul 23, 2016

Ok. Just seen your reply in #367.

I'll submit the PR to fix the return value for enhance then and will investigate what can be done about my particular use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants