• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Function类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testOnAndTrigger

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

    obj.on("event", new Function() {
        @Override
        public void f() {
            counter[0]++;
        }
    });
    obj.trigger("event");
    assertEquals("counter should be incremented", 1, counter[0]);

    obj.trigger("event");
    obj.trigger("event");
    obj.trigger("event");
    obj.trigger("event");
    assertEquals("counter should be incremented five times", 5, counter[0]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:20,代码来源:GwtTestCoreEvents.java


示例17: testFetchWithAnErrorResponseTriggersAnErrorEvent

import com.google.gwt.query.client.Function; //导入依赖的package包/类
public void testFetchWithAnErrorResponseTriggersAnErrorEvent() {
    class LocalCollection extends Collection<Model> {
        @Override
        public Promise sync(String method, Options options) {
            Function error = options.get("error");
            error.f();

            return null;
        }
    }

    final int[] counter = {0};

    LocalCollection collection = new LocalCollection();
    collection.on("error", new Function() {
        @Override
        public void f() {
            counter[0]++;
        }
    });
    collection.fetch();

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


示例18: testListenToOnceWithEventMapsCleansUpReferences

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

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

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

    a.listenToOnce(b, new HashMap<String, Function>() {
        {
            put("one", fn);
            put("two", fn);
        }
    });
    b.trigger("one");

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


示例19: testCreateWithWaitAddsModel

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

    Collection<SimpleSyncModel> collection = new Collection<SimpleSyncModel>(SimpleSyncModel.class);
    SimpleSyncModel model = new SimpleSyncModel();

    collection.on("add", new Function() {
        @Override
        public void f() {
            addCount[0]++;
        }
    });

    collection.create(model, O("wait", true));
    assertEquals(1, addCount[0]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:17,代码来源:GwtTestCoreCollection.java


示例20: testUnbindACallbackInTheMidstOfItFiring

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

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

    assertEquals("the callback should have been unbound.", 1, counter[0]);
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:19,代码来源:GwtTestCoreEvents.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Time类代码示例发布时间:2022-05-22
下一篇:
Java AHSClient类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap