The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

508177 (4) [Avatar] Offline
Hello Again...

I believe there may be an error in the Signal Binding Behavior listing 5.11 line 12...!/book/aurelia-in-action/chapter-5/v-3/point-266-73-73-0

currently reads:

disabled.bind="canAdd() & signal:'can-add-signal'">

but throws error that canAdd is not a function...

works when parens removed

disabled.bind="canAdd & signal:'can-add-signal'">

if that is indeed a mistake, could you maybe mention why it throws an error with the parens and not without...

thanks again,
Sean Hunter (29) [Avatar] Offline
Thanks Derek,

I looks like you're correct there (most likely a typo in the listing). Will check into it when I get some time later today smilie.

Sean Hunter (29) [Avatar] Offline
Hi Derek,

It looks like the listing is correct here. This should have parenthesis. I've put together a GistRun to show this in action:

I was able to re-produce the error by not modifying the canAdd function and leaving it as a getter function:

  get addDisabled(){
    return this.title.length === 0;

This changes it from being a function to a getter, and hence the exception.

If you change it to be this, you should get the desired result:

    return this.title.length === 0;

I'll look at re-working this example as it's not immediately clear what's going on. In fact the function is used in this case because it's only called once (when the view is loaded and binding is run), which means that it needs the signaler to execute to tell the binding to update. The correct approach to this problem in an app would be to either have the expression in-line, or to use a computed decorator.