angularjs - breeze.js metadata and firefox -
working on new spa angular , breeze , found firefox throws errors when chrome not. app able work offline when first load app (and therefore fill cache) works fine. if close browser , re-open it, app appears load correctly. click on triggers query breeze throws "json null" error.
i tried load metadata on client (importmetadata) based on advice found here on so. created dataservice hasservermetadata false reason firefox still triggers pulling metadata server. not happen chrome. used fiddler watch traffic in both cases. of course when firefox makes server call metadata has been populated , throws error entity type exists in metadata store.
has else had similar issue? thoughts why might happening in firefox not in chrome?
update: in factory use create breeze entity manager put in logging see if can figure out what's going on. here's fn.
function createmetadatastore() { console.log('loading metadata local js'); var store = new breeze.metadatastore(); console.log(window.app.metadata); model.configuremetadatastore(store); store.importmetadata(window.app.metadata); //used offline import of metadata console.log(store.hasmetadatafor(servicename)); console.log('should have metadata now'); return store; }
i see metadata logged expected, after store.importmetadata(window.app.metadata) call hasmetadatafor(servicename) call returns false. removed model.configuremetadatastore call had no effect. ideas why hasmetadatafor call returning false after importing metadata? going wrong?
update 2: not sure why had this, explicitly adding data service store.adddataservice(dataservice); right after create store did trick. else if ever run situation.
update 3: okay, adddataservice trick fixed 1 problem original 'json null' error resurfaced. have tracked down , put here in case else runs this. issue lz-string.js library use compress data local storage. turns out have use compresstoutf16 , decompressfromutf16 plain compress , decompress functions don't work on firefox. (http://pieroxy.net/blog/pages/lz-string/guide.html)
so chain of events was: 1. load data server, compress , store in local storage. 2. when loading app offline, pull compressed data local storage, decompress , pass breeze.importentities - failed.
i tested null when getting local storage, , passed. unfortunately, call import entities never received json data. switching utf16 versions of lz-string functions solved problem. works in firefox , chrome without issues.
Comments
Post a Comment