org.stjs.javascript.annotation
Annotation Type JavascriptFunction


@Target(value=TYPE)
@Retention(value=RUNTIME)
public @interface JavascriptFunction

This annotation annotates interfaces that are used to simulate Javascript functions. When implementing inline one of those interfaces, the generated Javascript code will be an anonymous function. Consequently whenever in the code the unique method of this interface is called, it will be generated a direct call to the function. Example:

 doSomething(new Function1<P, R>() {
        public R $invoke(P param) {
                return null;
        }
 });
 
will generate:
  doSomething(function(param) {
        });
 
And
 Function1<String,Integer> f = ...;
 Integer x = f.$invoke("test");
 
will generate:
 var f = ...;
 var x = f("test");
 

Author:
acraciun



Copyright © 2012. All Rights Reserved.