[ALOY-733] Alloy controller inheritance
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | n/a |
Status | Resolved |
Resolution | Needs more info |
Resolution Date | 2014-01-17T18:25:31.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | alloy, inheritance |
Reporter | Carter Lathrop |
Assignee | Tim Poulsen |
Created | 2013-07-08T11:16:57.000+0000 |
Updated | 2014-01-17T18:25:31.000+0000 |
Description
Suppose there is a view - "base.xml" and its associated controller - "base.js". Now, I wish to inherit this controller in order to create a new view via this new controller say, "descendant.js".
From my understanding of Alloy inheritance, if i use exports.baseController = "base" as the 1st line in "descendant.js", I should be able to access all exported functions of "base.js". However, I've found that this is in fact not the case.
Suppose there is a button in the view "base.xml" and on clicking it an event listener say, speak(), in "base.js" is called. I export it by assigning it to exports object using "exports.speak = speak;". Now in "descendant.js" when i override this speak function and try to call it in order to perform different actions for the same event of clicking the button, the same speak function of the "base.js" is called and not the overridden speak() of "descendant.js".
Please address this issue. If this issue is solved, it would help me use a single view say "base.xml" for a host of views whose controllers all inherit the "base.js" controller and respond to the same events in a polymorphic way. This would make using alloy MVC hugely beneficial.
Please provide a test case (minimal app) that demonstrates what you're trying to do. Also describe clearly what behavior you expect compared to what happens currently. The existing problem description is hard to follow which makes it hard to see where the existing inheritance model falls short of your expectations.