本文整理汇总了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);
}
示例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));
}
}
示例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);
}
示例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() ) );
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}