I have an idea that I would like to ask in Jira but first I'd like to know your opinion about it. I need to define some events that must be triggered only once, and some other that I need to be debounced.
index.xml
<Alloy> <Window onPostlayout="postlayout"> <Button onClick="click" title="click me" /> </Window> </Alloy>index.js
function postlayout() { $.index.removeEventListener('postlayout', postlayout); Ti.API.info('Post layout run once!'); }; function click() { debouncedClick(); }; var clickOnced = _.debounce(function () { Ti.API.info('Debounced click'); }, 700, true);I always have to write this kind of code which is quite not cool. I tried to use this king of code (see below) which was quite cool but it doesn't work because of this https://jira.appcelerator.org/browse/ALOY-969
index.js
var postlayout = _.once(function () { Ti.API.info('Post layout run once!'); }); var click = _.debounce(function () { Ti.API.info('Debouncde click'); }, 700, true);Here is a solution I would like to have in Alloy, based only on Alloy
index.xml
<Alloy> <Window oncePostlayout="postlayout"> <Button ondebounceClick="click" title="click me" /> </Window> </Alloy>What I was thinking is to make my own module, but I know I'll be tired to write ns="my.own.eventModule" every where, and what about fields that needs more than one namespaces?
Then I ask you it here : is it a good idea?
Of course, the decision about syntax should be discussed and taken. We could have this <Window onPostlayout:once="postlayout"><Button onClick:debounce="click" /><ScrollView onScroll:throttle="scroll" /></Window> (this is not nice xml) or other idea?
The parameters of debounce, throttle, etc. have a default value defined by the Alloy, but could be overloaded by the config.json, or in the parameter value like <Button onClick="click,debounce,700" /> ...
Than you for your returns