Saturday, October 5, 2019

Re: ClassCastException in some browser, but not others (

OK, this works --> IDBDatabase idb = Js.<IDBDatabase> uncheckedCast(idbr.result);

		@SuppressWarnings({ "unchecked" })  	public static void initIndexedDb() {    		IDBFactory idbf = IndexedDbGlobal.indexedDB;  		IDBOpenDBRequest idbr = idbf.open(INDEXEDDB_NAME);  		  		idbr.onsuccess = new OnsuccessFn() {    			@Override  			public Object onInvoke(elemental2.dom.Event p0) {    				// fails w java.lang.ClassCastException  				// IDBDatabase idb = (IDBDatabase) idbr.result;  				// IDBDatabase idb = Js.<IDBDatabase> cast(db);    				//this works  				IDBDatabase idb = Js.<IDBDatabase> uncheckedCast(idbr.result);    				DOMStringList dsl = idb.objectStoreNames;    				dsl.asList().forEach(s -> {  					Log.info("FOUND DB " + s);  				});    				return idbr.result;  			}  		};    		idbr.onerror = new OnerrorFn() {    			@Override  			public Object onInvoke(elemental2.dom.Event p0) {  				Log.error("OnerrorFn " + p0.type);  				return null;  			}  		};  	}  

On Sat, Oct 5, 2019 at 10:47 PM Shawn <shawn@koyuru.com> wrote:
Meant to add that I am sure indexeddb is supported in all the browsers I am using.

Here is the code again ... sorry about the previous formatting.

IDBFactory idbf = IndexedDbGlobal.indexedDB;

IDBOpenDBRequest idbr = idbf.open(INDEXEDDB_NAME);

 

idbr.onsuccess = new OnsuccessFn() {


@Override

public Object onInvoke(elemental2.dom.Event p0) {

 

                                        //error is next

idb = (IDBDatabase)  idbr.result;


DOMStringList dsl = idb.objectStoreNames;


dsl.asList().forEach(s -> {

Log.error("FOUND DB " + s);

});

 

return idbr.result;

}

};


On Chrome desktop, I find the indexeddb I created in handwritten js code.  I don't get why there is a ClassCastException in some browsers.  Is elemental2-indexeddb or gxt 2.9 (HEAD) not supported everywhere?

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/cbc724a1-5b8b-4478-8119-02af3d279c2b%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAEQ-_W11k9ze2bQnnB9K_fiGhna1f8AkmO25pLKYqmbA9vy1OQ%40mail.gmail.com.

No comments:

Post a Comment