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


Java Js类代码示例

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


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

示例1: method1

import jsinterop.base.Js; //导入依赖的package包/类
@JsOverlay
public final Object method1(String foo, double bar, boolean baz) {
  return method1(
      Js.<Child.Method1FooUnionType>uncheckedCast(foo),
      Js.<Child.Method1BarUnionType>uncheckedCast(bar),
      baz);
}
 
开发者ID:google,项目名称:jsinterop-generator,代码行数:8,代码来源:Child.java

示例2: eventSourceSubscription

import jsinterop.base.Js; //导入依赖的package包/类
private <T> void eventSourceSubscription(Subscriber<T> s) {
    final EventSource source = new EventSource(uri());
    final QueuedProducer<T> producer = new QueuedProducer<>(s);
    try {
        s.add(subscribeEventListener(source, "message", evt -> {
            producer.onNext(parse(Js.<MessageEvent<String>>cast(evt).data));
        }));
        s.add(subscribeEventListener(source, "open", evt -> {
            log.fine("Connection opened: " + uri());
        }));
        s.add(subscribeEventListener(source, "error", evt -> {
            log.log(Level.SEVERE, "Error: " + evt);
            if (source.readyState == source.CLOSED) {
                producer.onError(new RuntimeException("Event source error"));
            }
        }));
        s.setProducer(producer);
        s.add(Subscriptions.create(() -> {
            // hack because elemental API EventSource.close is missing
            Js.<MessagePort>uncheckedCast(source).close();
        }));
    } catch (Throwable e) {
        log.log(Level.FINE, "Received http error for: " + uri(), e);
        s.onError(new RuntimeException("Event source error", e));
    }
}
 
开发者ID:ibaca,项目名称:autorest-streaming-example,代码行数:27,代码来源:XhrResourceBuilder.java

示例3: readArray

import jsinterop.base.Js; //导入依赖的package包/类
@Override
public String[] readArray(JsonReader reader) {
    JsArray<JsString> jsArray = new JsArray<>();
    reader.beginArray();
    while (JsonToken.END_ARRAY != reader.peek()) {
        if (JsonToken.NULL == reader.peek()) {
            reader.skipValue();
            jsArray.push(null);
        } else {
            jsArray.push((JsString) Js.cast(reader.nextString()));
        }
    }
    reader.endArray();

    return reinterpretCast(jsArray);
}
 
开发者ID:vegegoku,项目名称:gwt-jackson-apt,代码行数:17,代码来源:JsStringArrayReader.java

示例4: scheduleRender

import jsinterop.base.Js; //导入依赖的package包/类
/**
 * Schedule this component for re-rendering.
 * The component re-renders when state or props change but calling this method is another way to
 * schedule the component to be re-rendered.
 *
 * <p>If the force parameter is true then the {@link #shouldComponentUpdate(BaseProps, BaseState, BaseContext)} will be skipped
 * and it is equivalent to calling forceUpdate() on the native react component. See the
 * <a href="https://reactjs.org/docs/react-component.html#forceupdate">React Component documentation</a> for more
 * details.</p>
 *
 * <p>If the force parameter is true then the {@link #shouldComponentUpdate(BaseProps, BaseState, BaseContext)} will be
 * invoked. This is equivalent to calling setState({}) on the native react component.</p>
 *
 * @param force true to skip shouldComponentUpdate during re-render, false otherwise.
 */
protected final void scheduleRender( final boolean force )
{
  if ( ReactConfig.checkComponentStateInvariants() )
  {
    apiInvariant( () -> ComponentPhase.UNMOUNTING != _phase,
                  () -> "Incorrectly invoked scheduleRender() on " + this + " when component is " +
                        "unmounting or has unmounted." );
  }
  if ( force )
  {
    component().forceUpdate();
  }
  else
  {
    // This schedules a re-render but will not skip shouldComponentUpdate
    component().setState( ( p, s ) -> Js.uncheckedCast( JsPropertyMap.of() ) );
  }
}
 
开发者ID:react4j,项目名称:react4j,代码行数:34,代码来源:Component.java

示例5: isObjectShallowModified

import jsinterop.base.Js; //导入依赖的package包/类
/**
 * We assume the two objects passed are js objects and we compare the objects have the same key-value
 * pairs skipping keys in the skip list.
 *
 * @param o1       the first object.
 * @param o2       the second object.
 * @param skipList an array of keys to ignore during comparison.
 * @return true if the two objects are considered modified.
 */
public static boolean isObjectShallowModified( @Nullable final Object o1,
                                               @Nullable final Object o2,
                                               @Nonnull final String... skipList )
{
  if ( null == o1 || null == o2 || !Js.typeof( o1 ).equals( "object" ) || !Js.typeof( o2 ).equals( "object" ) )
  {
    return !Js.isTripleEqual( o1, o2 );
  }
  final String[] keys = JsObject.keys( Js.uncheckedCast( o1 ) );
  if ( 0 == skipList.length && JsObject.keys( Js.uncheckedCast( o2 ) ).length != keys.length )
  {
    return true;
  }
  for ( final String key : keys )
  {
    if ( !shouldSkip( key, skipList ) &&
         !Js.isTripleEqual( Js.asPropertyMap( o1 ).get( key ), Js.asPropertyMap( o2 ).get( key ) ) )
    {
      return true;
    }
  }

  return false;
}
 
开发者ID:react4j,项目名称:react4j,代码行数:34,代码来源:JsUtil.java

示例6: outputStatus

import jsinterop.base.Js; //导入依赖的package包/类
private void outputStatus( @Nonnull final ObservablePromise<Response, Object> observablePromise )
{
  final ObservablePromise.State state = observablePromise.getState();
  final Response response = ObservablePromise.State.FULFILLED == state ? observablePromise.getValue() : null;
  final elemental2.core.JsError error =
    ObservablePromise.State.REJECTED == state ? Js.cast( observablePromise.getError() ) : null;
  final String message =
    "Promise State: " + state +
    ( null != response ? " - Response: " + response.status + ": " + response.statusText : "" ) +
    ( null != error ? " - Error: " + error.message : "" );
  DomGlobal.console.log( message );
  DomGlobal.document.querySelector( "#app" ).textContent = message;
}
 
开发者ID:arez,项目名称:arez,代码行数:14,代码来源:ObservablePromiseExample.java

示例7: getConstructorFunction

import jsinterop.base.Js; //导入依赖的package包/类
@Nonnull
private static ComponentConstructorFunction<BaseProps, BaseContext> getConstructorFunction() {
  final ComponentConstructorFunction<BaseProps, BaseContext> componentConstructor = NativeReactComponent::new;
  if ( ReactConfig.enableComponentNames() ) {
    Js.asPropertyMap( componentConstructor ).set( "displayName", "BasicHandlerComponent" );
  }
  return componentConstructor;
}
 
开发者ID:react4j,项目名称:react4j,代码行数:9,代码来源:BasicHandlerComponent_.java

示例8: create_handleFoo

import jsinterop.base.Js; //导入依赖的package包/类
@Nonnull
private CustomHandlerComponent.CustomHandler create_handleFoo() {
  final CustomHandlerComponent.CustomHandler handler = arg0 -> this.handleFoo(arg0);
  if( ReactConfig.enableComponentNames() ) {
    JsObject.defineProperty( Js.cast( handler ), "name", Js.cast( JsPropertyMap.of( "value", "CustomHandlerComponent.handleFoo" ) ) );
  }
  return handler;
}
 
开发者ID:react4j,项目名称:react4j,代码行数:9,代码来源:CustomHandlerComponent_.java

示例9: getConstructorFunction

import jsinterop.base.Js; //导入依赖的package包/类
@Nonnull
private static ComponentConstructorFunction<BaseProps, BaseContext> getConstructorFunction() {
  final ComponentConstructorFunction<BaseProps, BaseContext> componentConstructor = NativeReactComponent::new;
  if ( ReactConfig.enableComponentNames() ) {
    Js.asPropertyMap( componentConstructor ).set( "displayName", "CustomHandlerButParametersIgnoredComponent" );
  }
  return componentConstructor;
}
 
开发者ID:react4j,项目名称:react4j,代码行数:9,代码来源:CustomHandlerButParametersIgnoredComponent_.java

示例10: create_handleFoo

import jsinterop.base.Js; //导入依赖的package包/类
@Nonnull
private CustomHandlerButParametersIgnoredComponent.CustomHandler create_handleFoo() {
  final CustomHandlerButParametersIgnoredComponent.CustomHandler handler = arg0 -> this.handleFoo();
  if( ReactConfig.enableComponentNames() ) {
    JsObject.defineProperty( Js.cast( handler ), "name", Js.cast( JsPropertyMap.of( "value", "CustomHandlerButParametersIgnoredComponent.handleFoo" ) ) );
  }
  return handler;
}
 
开发者ID:react4j,项目名称:react4j,代码行数:9,代码来源:CustomHandlerButParametersIgnoredComponent_.java

示例11: create_handleFoo

import jsinterop.base.Js; //导入依赖的package包/类
@Nonnull
private EventHandler.Procedure create_handleFoo() {
  final EventHandler.Procedure handler = () -> this.handleFoo();
  if( ReactConfig.enableComponentNames() ) {
    JsObject.defineProperty( Js.cast( handler ), "name", Js.cast( JsPropertyMap.of( "value", "CustomNameComponent.fox" ) ) );
  }
  return handler;
}
 
开发者ID:react4j,项目名称:react4j,代码行数:9,代码来源:CustomNameComponent_.java

示例12: getConstructorFunction

import jsinterop.base.Js; //导入依赖的package包/类
@Nonnull
private static ComponentConstructorFunction<BaseProps, BaseContext> getConstructorFunction() {
  final ComponentConstructorFunction<BaseProps, BaseContext> componentConstructor = NativeReactComponent::new;
  if ( ReactConfig.enableComponentNames() ) {
    Js.asPropertyMap( componentConstructor ).set( "displayName", "CustomHandlerMultipleArgsComponent" );
  }
  return componentConstructor;
}
 
开发者ID:react4j,项目名称:react4j,代码行数:9,代码来源:CustomHandlerMultipleArgsComponent_.java

示例13: getConstructorFunction

import jsinterop.base.Js; //导入依赖的package包/类
@Nonnull
private static ComponentConstructorFunction<BaseProps, BaseContext> getConstructorFunction() {
  final ComponentConstructorFunction<BaseProps, BaseContext> componentConstructor = NativeReactComponent::new;
  if ( ReactConfig.enableComponentNames() ) {
    Js.asPropertyMap( componentConstructor ).set( "displayName", "ComponentWithEventHandler" );
  }
  return componentConstructor;
}
 
开发者ID:react4j,项目名称:react4j,代码行数:9,代码来源:ComponentWithEventHandler_.java

示例14: getConstructorFunction

import jsinterop.base.Js; //导入依赖的package包/类
@Nonnull
private static ComponentConstructorFunction<BaseProps, BaseContext> getConstructorFunction() {
  final ComponentConstructorFunction<BaseProps, BaseContext> componentConstructor = NativeReactComponent::new;
  if ( ReactConfig.enableComponentNames() ) {
    Js.asPropertyMap( componentConstructor ).set( "displayName", "ComponentWithAnnotatedParameterEventHandler" );
  }
  return componentConstructor;
}
 
开发者ID:react4j,项目名称:react4j,代码行数:9,代码来源:ComponentWithAnnotatedParameterEventHandler_.java

示例15: create_handleFoo

import jsinterop.base.Js; //导入依赖的package包/类
@Nonnull
private ComponentWithAnnotatedParameterEventHandler.CustomHandler2 create_handleFoo() {
  final ComponentWithAnnotatedParameterEventHandler.CustomHandler2 handler = () -> this.handleFoo();
  if( ReactConfig.enableComponentNames() ) {
    JsObject.defineProperty( Js.cast( handler ), "name", Js.cast( JsPropertyMap.of( "value", "ComponentWithAnnotatedParameterEventHandler.handleFoo" ) ) );
  }
  return handler;
}
 
开发者ID:react4j,项目名称:react4j,代码行数:9,代码来源:ComponentWithAnnotatedParameterEventHandler_.java


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