Is it possible to use the GWT Elemental collections in a non-elemental app?

858 Views Asked by At

Is it possible to use the Elemental collections (elemental.util.Collections, elemental.util.ArrayOfInt, elemental.util.MapFromStringTo, etc) in a non-elemental GWT app. I'm using these modules already:

<!-- Inherit the core Web Toolkit stuff.                        -->
<inherits name='com.google.gwt.user.User' />

<!-- Inherit the RequestBuilder stuff.                        -->
<inherits name="com.google.gwt.http.HTTP" />


<!--  Inherit GQuery -->
<inherits name='com.google.gwt.query.Query' />

But I'd like to start using the lightweight Elemental collections rather than Java ArrayList and HashMap. Is that possible? Would it be fairly easy to port from Elemental into it's own module for this purpose? Thanks for you help.

2

There are 2 best solutions below

0
On BEST ANSWER

Sure, all you have to do is include the following declaration in your module descriptor (*.gwt.xml):

<inherits name="elemental.Elemental"/>

See the elemental example on the GWT trunk.

0
On

I could not get the GWT Elemental projects silvercomet or simple to execute in FireFox.

However a below simple elemental test code executes in FireFox and Chrome along with gwt user and http modules.

Module File.

<module rename-to="HelloElemental">
    <inherits name="elemental.Elemental" />
    <!-- Inherit the core Web Toolkit stuff. -->
    <inherits name='com.google.gwt.user.User' />
    <!-- Inherit the RequestBuilder stuff. -->
    <inherits name="com.google.gwt.http.HTTP" />
    <add-linker name="xsiframe" />
    <set-configuration-property name="devModeRedirectEnabled" value="true" />
    <entry-point class="com.google.silvercomet.client.Main" />
</module>

Entry Point Class -

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;

import elemental.util.ArrayOf;
import elemental.util.Collections;

public class Main implements EntryPoint
{
    public void onModuleLoad()
    {
        ArrayOf<String> items = Collections.arrayOf();
        items.insert( 0, "First" );
        Window.alert( items.get( 0 ) );
    }
}