[ALOY-504] Remove event listeners on dataFunction
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Medium |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Models, Runtime, XML |
Labels | alloy, bind, bindings, controller, data, model, views |
Reporter | Fokke Zandbergen |
Assignee | Feon Sua Xin Miao |
Created | 2012-12-31T20:08:13.000+0000 |
Updated | 2018-08-20T23:06:48.000+0000 |
Description
This issue is related to the following topic on Google Groups:
https://groups.google.com/forum/?fromgroups=#!topic/appc-ti-alloy/7TKs1YiLrNk
It asks for:
The 2nd point of this issue can be dropped. The first and last are already in Alloy 1.1, now we have the
dataFunction
attribute. The 2nd point now has it's own issue with more details and examples: TC-2188.ACtually, the 3rd point is not resolved. Although you can expose the binding function with an explicit name, it is still always fired on your behalf, you just have the ability to do it manually as well. I'm pondering now if defining the name should imply that you want to be in full control of when binding fires, or if a secondary attribute should indicate that. I guess my concern is that if you are manually defining the name of the function and when it will be called, why bother doing the binding in markup at all? Why not just do it all in code?
I would say that the very reason for wanting to name the data-binding method is that you want to call it yourself. So yes, I suggest to drop the listeners if
dataFunction
was used. Why bother you ask? Well, because you want your views to show all there is to it and not have some UI hidden away in the controller.+1 for dropping the listeners if dataFunction is used.
I'm trying to plan out time for this ticket. Am I correct that in the end, all that's being asked for is removing the listeners on dataFunction? Since that could potentially break existing apps, would you see any issues with creating a new function that didn't have listeners and keeping them on dataFunction()?
I gave a detailed description in a new ticket: ALOY-639 I think we should have tackled both issues together, as now indeed we might break apps unless we introduce a new attribute and I'd hate that. Actually I doubt how many people actually use
dataFunction
. I don't, because I don't see much use in it without the additional functionality described in ALOY-639, since for what it does now you could as well just trigger afetch
or other event on the collection. So, if it was up to me... just change the behavior ofdataFunction
to meet ALOY-639 and add a breaking note to the release notes. It'll be just a few apps.I know this ticket is quite old, but point number 2 in the initial request would be a huge bonus. It's really awkward having to work with Alloy Models all the time for dataCollection to work. Sometimes that's just not possible with a certain APIs that you get (we use the sqlrest adaptor with Alloy Models), which means you then have to resort to some nasty workarounds throughout your project. Being able to pass in a simple array would be amazing and a huge time saver.
[~jyounus] I agree it would be a great improvement, which is now requested under ALOY-639. If you have time to give it a go, the required changes should be in https://github.com/appcelerator/alloy/blob/master/Alloy/commands/compile/compilerUtils.js#L914.
Thanks for your reply Fokke! This look promising. I won't have time to checkout the current progress on Alloy, I'll have to wait until those changes are inside the latest stable Alloy update. But really looking forward to stop using these workarounds for binding data!