Skip to content

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

Merged
rwjblue merged 1 commit into
emberjs:masterfrom
GavinJoyce:gj/api-docs
Mar 13, 2019
Merged

rwjblue merged 1 commit into
emberjs:masterfrom
GavinJoyce:gj/api-docs

Conversation

@GavinJoyce

Copy link
Copy Markdown
Member

part of #2

@rwjblue rwjblue left a comment

Copy link
Copy Markdown
Member

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

rwjblue commented Mar 6, 2019

Copy link
Copy Markdown
Member

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

GavinJoyce commented Mar 11, 2019 •

Copy link
Copy Markdown
Member Author

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?

@rwjblue rwjblue left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member Author

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

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

rwjblue commented Mar 13, 2019

Copy link
Copy Markdown
Member

Thank you!

@GavinJoyce
GavinJoyce deleted the gj/api-docs branch March 13, 2019 11:55
aklkv pushed a commit to aklkv/ember-render-modifiers that referenced this pull request Feb 18, 2026
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