public object GetDefinition() { Func <jElement, string, Action, Action> removeClass = (element, className, doneCallback) => { // keep tracks of the timer Promise timerPromise = null; // the cancel/end animation funcion Action cancelCallback = () => { Interval.Cancel(timerPromise); }; // the function that updated the control Action <Element> OnTick = (el) => { int l = el.TextContent.Length; if (l < scrolltext.Length) { el.TextContent = scrolltext.Substring(0, l + 1); } else { cancelCallback(); // stops the animation doneCallback(); } }; if (className == "ng-hide") { // We're unhiding the element, i.e. showing the element var el = element[0]; el.TextContent = "*"; timerPromise = Interval.Set(() => OnTick(el), 100); } else { doneCallback(); } return(cancelCallback); }; // Action<bool> addClass(element, string className, Action done) Action <List <Element>, string, Action> addClass = (element, className, done) => { if (className == "ng-hide") { // We're hiding the element done(); } else { done(); } }; return(new { addClass = addClass, removeClass = removeClass }); }