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

Fixes #251 - Output of render should be Promise compatible. #423

Merged

Conversation

austinkelleher
Copy link
Member

No description provided.

@coveralls
Copy link

coveralls commented Nov 11, 2016

Coverage Status

Coverage increased (+0.03%) to 71.587% when pulling 0310d77 on austinkelleher:251-render-promise into da11d73 on marko-js:master.

@coveralls
Copy link

coveralls commented Nov 11, 2016

Coverage Status

Coverage increased (+0.03%) to 71.587% when pulling beb8652 on austinkelleher:251-render-promise into da11d73 on marko-js:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 71.494% when pulling 41fbe7a on austinkelleher:251-render-promise into abe0e2d on marko-js:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 71.494% when pulling 41fbe7a on austinkelleher:251-render-promise into abe0e2d on marko-js:master.

@patrick-steele-idem
Copy link
Contributor

If out.error() is called the finish event is still emitted. That would result in both reject and resolve being called. I'm not sure what the Promise spec says should happen when that occurs, but we should probably add code to make sure that resolve is not called when reject is called. Do you mind investigating that?

@Hesulan
Copy link
Contributor

Hesulan commented Nov 13, 2016

The Promises/A+ specification requires that a Promise instance must only ever handle the very first call to either resolve or reject, and ignore all further attempts at either. So as long as the correct one is called first it doesn't matter what happens after, the resolved/rejected Promise instance becomes immutable.

@Hesulan
Copy link
Contributor

Hesulan commented Nov 13, 2016

That being said, do be aware that a fulfilled Promise exhibits shallow immutability; the resolved/rejected value is effectively a const in that you cannot replace it, but you can still modify the result's properties. And since calling resolve or reject doesn't cause the function to exit, it's entirely possible to accidentally mutate the result.


out.write('1');
out.error(new Error('test'));
out.write('2');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't you missing an out.end()?

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

Successfully merging this pull request may close these issues.

4 participants