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

{{did-insert}}, {{did-update}} and {{will-destroy}} API docs #8

Merged
merged 1 commit into from
Mar 13, 2019

Conversation

GavinJoyce
Copy link
Member

part of #2

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

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

Lookin' good! I think we should also mention that the function is not bound to the template context by default, and show how the user might do that (e.g. via action or using ember-bind-helper).

@rwjblue
Copy link
Member

rwjblue commented Mar 6, 2019

Also, I'm happy to land PR's like this iteratively...

@GavinJoyce GavinJoyce force-pushed the gj/api-docs branch 2 times, most recently from d27b454 to afbad69 Compare March 11, 2019 15:13
@GavinJoyce GavinJoyce changed the title [WIP] API docs {{did-insert}} API docs Mar 11, 2019
@GavinJoyce
Copy link
Member Author

GavinJoyce commented Mar 11, 2019

I think we should also mention that the function is not bound to the template context by default, and show how the user might do that (e.g. via action or using ember-bind-helper)

I've added a short section on using action to bind the component context. It would be nicer to provide a simple example of when to use this, I couldn't think of one though. Perhaps you have an example that I could borrow?

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

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

I think the "simplest" demo would be some sort of "refs" type thing:

<div {{did-insert (action this.setupSpecialSauceElement)}} class="special-sauce"></div>

Then using the element and this in that method (perhaps to setup some external DOM plugin e.g. tinymce, mobiledoc, etc).

@GavinJoyce
Copy link
Member Author

Thanks, I tried to keep it as simple as possible so I added the following example:


By default, the executed function will be unbound. If you would like to access the component context in your function, use the action helper as follows:

<div {{did-insert (action this.incrementCount)}}>first</div>
<div {{did-insert (action this.incrementCount)}}>second</div>

<p>{{this.count}} elements were rendered</p>
export default Component.extend({
  @tracked count = 0;

  incrementCount() {
    this.count++;
  }
});

@GavinJoyce GavinJoyce changed the title {{did-insert}} API docs {{did-insert}}, {{did-update}} and {{will-destroy}} API docs Mar 13, 2019
@GavinJoyce
Copy link
Member Author

I've added docs for {{did-update}} and {{will-destroy}} too

@GavinJoyce GavinJoyce mentioned this pull request Mar 13, 2019
7 tasks
@rwjblue rwjblue merged commit 48faeb4 into emberjs:master Mar 13, 2019
@rwjblue
Copy link
Member

rwjblue commented Mar 13, 2019

Thank you!

@GavinJoyce GavinJoyce deleted the gj/api-docs branch March 13, 2019 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants