New to ember, I am having trouble making sense of this code:
On the front-end, is a simple form, that is used to submit user text input as feedback
<Form @onSubmit={{perform this.submitFeedback}}>
<TextField
@multiline={{3}}
@placeholder="Additional comments"
@autoFocus={{not @shouldRenderOptions}}
@value={{this.feedbackText}}
@disabled={{this.submitFeedback.isRunning}}
@onChange={{action (mut this.feedbackText)}}
/>
<ButtonGroup>
<Button
@text="Send feedback"
@loading={{this.submitFeedback.isRunning}}
@onClick={{perform this.submitFeedback}}
/>
<Button
@text="Cancel"
@plain={{true}}
@onClick={{action @onCancel}}
/>
</ButtonGroup>
</Form>
Backing it up, on the .js Component I have:
export default class FeedbackFormComponent extends Component {
/**
* Callback when the feedback form is submitted
* Provides `feedbackText` and `wasContentUseful`
* as arguments.
*
* @type {Function}
* @public
*/
onSubmitFeedback = resolve;
@dropTask
submitFeedback = function* submitFeedback() {
let { feedbackText, wasContentUseful, onSubmitFeedback } = this;
yield onSubmitFeedback(wasContentUseful, feedbackText);
};
}
How can I track, what this submission is actually doing? What is resolve doing in a situation like this? onSubmitFeedback = resolve;
Looks like that is referencing a function that acts like Promise.resolve, according to the documentation.
The referenced function has this signature, where it also takes in 2 arguments like onSubmitFeedback does:
resolve (value, label)