Vheissu / aurelia-for-real-world-web-applications-book-feedback

Post feedback as issues here on Github for the Aurelia book. Be as descriptive and honest as you like.
15 stars 0 forks source link

.call #43

Closed wshayes closed 8 years ago

wshayes commented 8 years ago
Essentially it passes a function reference. You can pass in a function and then call it like a standard function. If you have a custom element and you allow users to pass through functions to be called by the custom element, like a close callback or something, this is what you will use.

The call binding functionality is not intended to be used for standard browser events. It is more of allowing functions to be passed through and calling the original function by reference.

I still don't understand what the .call binding does and the example further down didn't clear it up. Could you elaborate more on this?

opcodewriter commented 8 years ago

an example is a must have in the book.

my-view.js defines a create

export class MyView 
{
   @bindable create;
}

my-view.html calls create()

<template>
   <button type="button" click.delegate="create()">Create</button>
</template>

app.html passes create_now to my-view:

<template>
   <my-view create.call="create_now()"></my-view>
</template>

app.js

export class MyView 
{
    create_now() 
    {
    }
}

I should had created a gist :)

Vheissu commented 8 years ago

I absolutely agree guys, I will definitely add in some clarification for this in the next release.

Vheissu commented 8 years ago

I've made your above provided example @opcodewriter into a Gist accessible here and a Gist.run example here.

wshayes commented 8 years ago

Ahh! Thanks @opcodewriter - that is very clear now.

On Mar 30, 2016, at 2:37 AM, Dwayne Charrington notifications@github.com wrote:

I've made your above provided example @opcodewriter https://github.com/opcodewriter into a Gist accessible here https://gist.github.com/Vheissu/9b49c26623f4dc6e63a0347ca48af6b3 and a Gist.run example here https://gist.run/?id=9b49c26623f4dc6e63a0347ca48af6b3.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/Vheissu/aurelia-for-real-world-web-applications-book-feedback/issues/43#issuecomment-203275657