当前位置: 首页>>代码示例>>Java>>正文


Java Function类代码示例

本文整理汇总了Java中com.google.gwt.query.client.Function的典型用法代码示例。如果您正苦于以下问题:Java Function类的具体用法?Java Function怎么用?Java Function使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Function类属于com.google.gwt.query.client包,在下文中一共展示了Function类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadScript

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public static Promise<Void, Exception> loadScript(String url, String... properties) {
    return new Promise<>((resolve, reject) -> {
        if (exists(properties)) {
            resolve.e(null);
        } else {
            Ajax.loadScript(url).done(new Function() {
                @Override
                public void f() {
                    resolve.e(null);
                }
            }).fail(new Function() {
                @Override
                public void f() {
                    reject.e(new Exception(url + " not loaded"));
                }
            });
        }
    });
}
 
开发者ID:spirylics,项目名称:x-gwt,代码行数:20,代码来源:XGWT.java

示例2: imports

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public static Promise imports(String... urls) {
    return new Promise<>((resolve, reject) -> GQuery.when(Arrays.stream(urls)
            .map(url -> url.endsWith(".js") ? Ajax.loadScript(url) : Ajax.importHtml(url))
            .toArray())
            .done(new Function() {
                @Override
                public void f() {
                    resolve.e(getArguments());
                }
            })
            .fail(new Function() {
                @Override
                public void f() {
                    reject.e(getArguments());
                }
            }));
}
 
开发者ID:spirylics,项目名称:x-gwt,代码行数:18,代码来源:XGWT.java

示例3: googleMapsApiPromise

import com.google.gwt.query.client.Function; //导入依赖的package包/类
@JsOverlay
public static Promise googleMapsApiPromise() {
    return new PromiseFunction() {
        @Override
        public void f(final Deferred deferred) {
            if ($("google-maps-api").isEmpty()) {
                $(body).append("<google-maps-api></google-maps-api>");
            }
            GQuery gMapsApi = $("google-maps-api");
            if (gMapsApi.prop("libraryLoaded", Boolean.class)) {
                deferred.resolve();
            } else {
                gMapsApi.on("api-load", new Function() {
                    @Override
                    public void f() {
                        deferred.resolve();
                    }
                });
            }
        }
    };
}
 
开发者ID:spirylics,项目名称:x-gwt,代码行数:23,代码来源:Polymer.java

示例4: undelegate

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public View undelegate(String eventName, String selector, Function listener) {
    if(eventName == null) {
        undelegateEvents();
    } else {
        eventName += ".delegateEvents" + this.cid;

        if(selector != null && !selector.isEmpty()) {
            this.$el.undelegate(selector, eventName);
        } else if(listener != null) {
            this.$el.unbind(eventName, listener);
        } else {
            ViewEventEntry viewEventEntry = delegatedEvents.get(eventName);

            this.$el.undelegate(viewEventEntry.selector, eventName);
            this.$el.unbind(eventName);
        }
        delegatedEvents.remove(eventName);
    }

    return this;
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:22,代码来源:View.java

示例5: testNestedSetMultipleTimes

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public void testNestedSetMultipleTimes() {
    final int[] count = {0};

    final Model model = new Model();

    model.on("change:b", new Function() {
        @Override
        public void f() {
            count[0]++;
        }
    });
    model.on("change:a", new Function() {
        @Override
        public void f() {
            model.set(O("b", true));
            model.set(O("b", true));
        }
    });
    model.set(O("a", true));

    assertEquals(1, count[0]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:23,代码来源:GwtTestCoreModel.java

示例6: testFinalChangeEventIsAlwaysFiredRegardlessOfInterimChanges

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public void testFinalChangeEventIsAlwaysFiredRegardlessOfInterimChanges() {
    final int[] count = {0};

    final Model model = new Model();
    model.on("change:property", new Function() {
        @Override
        public void f() {
            model.set("property", "bar");
        }
    });
    model.on("change", new Function() {
        @Override
        public void f() {
            count[0]++;
        }
    });
    model.set("property", "foo");

    assertEquals(1, count[0]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:21,代码来源:GwtTestCoreModel.java

示例7: testTriggerRouteEventOnRouterInstance

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public void testTriggerRouteEventOnRouterInstance() {
    final int[] counter = {0};

    router.on("route", new Function() {
        @Override
        public void f() {
            String name = getArgument(0);
            String[] args = getArgument(1);

            assertEquals("routeEvent", name);
            assertEquals(Arrays.asList("x"), Arrays.asList(args));

            counter[0]++;
        }
    });

    location.replace("http://example.com#route-event/x");
    History.get().checkUrl();

    assertEquals(1, counter[0]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:22,代码来源:GwtTestCoreRouter.java

示例8: testBindTwoCallbacksUnbindOnlyOne

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public void testBindTwoCallbacksUnbindOnlyOne() {
    final int[] counterA = {0};
    final int[] counterB = {0};
    Events obj = new Events();

    Function callback = new Function() {
        @Override
        public void f() {
            counterA[0]++;
        }
    };
    obj.on("event", callback);
    obj.on("event", new Function() {
        @Override
        public void f() {
            counterB[0]++;
        }
    });
    obj.trigger("event");
    obj.off("event", callback);
    obj.trigger("event");

    assertEquals("counterA should have only been incremented once.", 1, counterA[0]);
    assertEquals("counterB should have been incremented twice.", 2, counterB[0]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:26,代码来源:GwtTestCoreEvents.java

示例9: testRemoveAllEventsForASpecificContext

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public void testRemoveAllEventsForASpecificContext() {
    final int[] counter = {0};
    final Events obj = new Events();

    final Function incr = new Function() {
        @Override
        public void f() {
            counter[0]++;
        }
    };

    obj.on("x y all", incr);
    obj.on("x y all", incr, obj);
    obj.off(null, null, obj);
    obj.trigger("x y");

    assertEquals(4, counter[0]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:19,代码来源:GwtTestCoreEvents.java

示例10: once

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public T once(final String name, final Function callback, Object context) {
    if(callback == null) return (T)this;

    if(eventsSplitter.test(name)) {
        String[] names = name.split(eventsSplitter.getSource());
        for (String splittedName : names) {
            once(splittedName, callback, context);
        }
    } else {
        final OnceFunction onceCallback = new OnceFunction(name, callback) {
            @Override
            public void once() {
                off(getName(), this);
                getCallback().f(getArguments());
            }
        };
        on(name, onceCallback, context);
    }

    return (T)this;
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:22,代码来源:Events.java

示例11: testMultipleNestedChangesWithSilent

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public void testMultipleNestedChangesWithSilent() {
    final int[] count = {0};

    final Model model = new Model();

    model.on("change:x", new Function() {
        @Override
        public void f() {
            model.set(O("y", 1), O("silent", true));
            model.set(O("y", 2));
        }
    });
    model.on("change:y", new Function() {
        @Override
        public void f() {
            int value = getArgument(1);

            assertEquals(2, value);
            count[0]++;
        }
    });
    model.set(O("x", true));

    assertEquals(1, count[0]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:26,代码来源:GwtTestCoreModel.java

示例12: testAllCallbackListIsRetrievedAfterEachEvent

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public void testAllCallbackListIsRetrievedAfterEachEvent() {
    final int[] counter = {0};
    final Events obj = new Events();

    final Function incr = new Function() {
        @Override
        public void f() {
            counter[0]++;
        }
    };

    obj.on("x", new Function() {
        @Override
        public void f() {
            obj.on("y", incr).on("all", incr);
        }
    }).trigger("x y");
    assertEquals(2, counter[0]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:20,代码来源:GwtTestCoreEvents.java

示例13: testListenToOnceAndStopListening

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public void testListenToOnceAndStopListening() {
    final int[] counter = {0};

    Events a = new Events();
    Events b = new Events();

    final Function cb = new Function() {
        @Override
        public void f() {
            counter[0]++;
        }
    };

    a.listenToOnce(b, "all", cb);
    b.trigger("anything");
    b.trigger("anything");
    a.listenToOnce(b, "all", cb);
    a.stopListening();
    b.trigger("anything");

    assertEquals(1, counter[0]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:23,代码来源:GwtTestCoreEvents.java

示例14: listenToOnce

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public T listenToOnce(final Events obj, String name, Function callback) {
    if(callback == null) return (T)this;

    if(eventsSplitter.test(name)) {
        String[] names = name.split(eventsSplitter.getSource());
        for (String splittedName : names) {
            listenToOnce(obj, splittedName, callback);
        }
    } else {
        final OnceFunction onceCallback = new OnceFunction(name, callback) {
            @Override
            public void once() {
                stopListening(obj, getName(), this);
                getCallback().f(getArguments());
            }
        };
        listenTo(obj, name, onceCallback);
    }

    return (T)this;
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:22,代码来源:Events.java

示例15: testNestedChangeAttrWithSilent

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public void testNestedChangeAttrWithSilent() {
    final int[] count = {0};

    final Model model = new Model();
    model.on("change:y", new Function() {
        @Override
        public void f() {
            count[0]++;
        }
    });
    model.on("change", new Function() {
        @Override
        public void f() {
            model.set(O("y", true), O("silent", true));
            model.set(O("z", true));
        }
    });
    model.set(O("x", true));

    assertEquals(0, count[0]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:22,代码来源:GwtTestCoreModel.java


注:本文中的com.google.gwt.query.client.Function类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。