Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Passing a callback to a component - possible?

$
0
0
@alex we have two components: Chooser and List

Chooser has Chooser .onSelected

In your fiddle List is using Chooser .onSelected directly, yes, you are passing  Chooser . onSelected to can-event but you are doing it in List. So List has to know that Chooser has an onSelected function. This is what I am calling tight coupling.

List should not have to know about the methods in Chooser. You should be able to tell List to call whatever method you want, e.g. <list on-selected="{onSelected}">, this could called something else e.g. <list on-selected='{someCallbackFunctionName}'>, so List doesn't care about this naming at all. It should be able to call the callback regardless.

Makes sense?




Viewing all articles
Browse latest Browse all 3491

Trending Articles