You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.
Right now, the API only allows for the trigger to be a string or a RegEx. For my application, I want the trigger to fire every time the input is a prefix for a word within a dynamic list of words. As a workaround I, I created an object that matches the RegEx API that the current smart-area code uses.
To show what I mean, I have this:
varWordTrigger=function(){this.words=[];WordTrigger.prototype.exec=(text)=>{varlastSpaceIdx=lastWhitespaceIndex(text);varcurrToken=text.substring(lastSpaceIdx>=0 ? lastSpaceIdx+1 : 0).toLowerCase();if(currToken===''){returnnull;}varresults=setFilter(this.bigramDist.words,word=>_.startsWith(word,currToken)&&word!==currToken);varcompletions=results.map(result=>result.substring(currToken.length));if(_.isEmpty(results)){returnnull;}varretVal=[''];retVal.index=text.length;retVal.input=text;// The above 3 lines are just to appease the smart-area code// real results are stored in the 'results' propertyretVal.results=_.zipWith(results,completions,function(result,completion){return{'display': result,'item': completion};});returnretVal;};WordTrigger.prototype.addWord=(word)=>{this.words.push(word);};};
And in my areaConfig I just have this:
'trigger': new WordTrigger(), ...
This isn't a very clean workaround and I feel like it would be simple enough to just add support for trigger functions.
The text was updated successfully, but these errors were encountered:
sourabhdesai
changed the title
Allow a Trigger Function to the dropdown API
Allow a Trigger Function for the dropdown API
Dec 28, 2015
Right now, the API only allows for the trigger to be a string or a RegEx. For my application, I want the trigger to fire every time the input is a prefix for a word within a dynamic list of words. As a workaround I, I created an object that matches the RegEx API that the current smart-area code uses.
To show what I mean, I have this:
And in my
areaConfig
I just have this:This isn't a very clean workaround and I feel like it would be simple enough to just add support for trigger functions.
The text was updated successfully, but these errors were encountered: