use of elemental2.core.Function in project vue-gwt by Axellience.
the class VueGWTObserverManager method captureVueObserver.
/**
* Capture the Vue Observer by creating a Vue Instance on the fly
*/
private void captureVueObserver() {
HTMLScriptElement scriptElement = (HTMLScriptElement) DomGlobal.document.createElement("script");
scriptElement.text = "new Vue({created: function () {VueGWT.VueGWTObserverManager.get().customizeVueObserverPrototype(this.$data.__ob__.__proto__);}});";
DomGlobal.document.body.appendChild(scriptElement);
}
use of elemental2.core.Function in project vue-gwt by Axellience.
the class VueGWTTools method wrapMethod.
/**
* Proxy a method call to be warned when it called. This requires the
* function to be JsInterop (name shouldn't change at runtime). This used to
* observe Java Collections/Map. It won't be necessary in future versions of
* Vue.js based on ES6 proxies.
* @param object The object to observe
* @param methodName The name of the method to proxify
* @param afterMethodCall A callback called each time after the method has
* been executed
* @param <T> Type of the object the we Proxy
*/
public static <T> void wrapMethod(T object, String methodName, AfterMethodCall<T> afterMethodCall) {
Function method = (Function) ((JsPropertyMap) object).get(methodName);
WrappingFunction wrappingFunction = args -> {
Object result = method.apply(object, args);
afterMethodCall.execute(object, methodName, result, args);
return result;
};
((JsPropertyMap) object).set(methodName, wrappingFunction);
}
use of elemental2.core.Function in project vue-gwt by Axellience.
the class VueGWTTools method extendVueConstructorWithJavaPrototype.
/**
* Copy a Java class prototype to a VueComponent declaration. This allows
* VueComponent created by Vue to pass as an instance of the VueComponent
* class they implement.
* @param extendedVueJsConstructor The Vue.js constructor function to extend
* @param componentJavaPrototype The VueComponent class JS prototype to
* extend with
* @param <T> The type of the VueComponent
*/
public static <T extends VueComponent> void extendVueConstructorWithJavaPrototype(VueJsConstructor<T> extendedVueJsConstructor, ComponentJavaPrototype<T> componentJavaPrototype) {
JsPropertyMap vueProto = (JsPropertyMap) ((JsPropertyMap) extendedVueJsConstructor).get("prototype");
JsObject vueProtoJsObject = ((JsObject) vueProto);
componentJavaPrototype.forEach(protoProp -> {
if (!vueProtoJsObject.hasOwnProperty(protoProp))
vueProto.set(protoProp, componentJavaPrototype.get(protoProp));
});
}
use of elemental2.core.Function in project kie-wb-common by kiegroup.
the class DNDListComponentView method getNextElement.
private Element getNextElement(final Element element, final Function<HTMLElement, Boolean> function) {
final int nextElementPosition = Position.getY(element) + 1;
final HTMLElement next = querySelector(getDragArea()).getDraggableElement(nextElementPosition).orElse(null);
if (function.apply(next) || next == null) {
return next;
}
return getNextElement(next, function);
}
use of elemental2.core.Function in project kie-wb-common by kiegroup.
the class PromisesMock method promisify.
@SuppressWarnings("unchecked")
public static Promises promisify(final Promises promises) {
doAnswer(invocationOnMock -> {
final Caller caller = (Caller) invocationOnMock.getArguments()[0];
final Function call = (Function) invocationOnMock.getArguments()[1];
final Promise<Object>[] promise = new Promise[1];
final Object service = caller.call(response -> promise[0] = PromiseMock.success(response));
call.apply(service);
return promise[0];
}).when(promises).promisify(any(Caller.class), any(Function.class));
return promises;
}
Aggregations