Ticket #2229 (closed enhancement: wontfix)
Make using Dojo Event with Dojo Storage more elegant
| Reported by: | bradneuberg | Owned by: | bradneuberg |
|---|---|---|---|
| Priority: | high | Milestone: | 1.4 |
| Component: | Storage/Flash | Version: | 0.4.1 |
| Severity: | normal | Keywords: | |
| Cc: |
Description (last modified by BradNeuberg) (diff)
Right now, if you use Dojo Event with Dojo Storage to know when the storage subsystem is loaded, you have to do an ugly block like this:
if(dojo.storage.manager.isInitialized() == false){
dojo.event.connect(dojo.storage.manager,
"loaded", Moxie, Moxie.initialize);
}else{
dojo.event.connect(dojo, "loaded",
Moxie, Moxie.initialize);
}
Thats just ugly boilerplate; I'd like to make it just be:
dojo.event.connect(dojo.storage.manager,
"loaded", Moxie, Moxie.initialize);
However, here's the problem; if we reach that dojo.event.connect and the storage system is already initialized, then Moxie.initialize never gets called! We need to find a way to have that "loaded" event fired even after we have been loaded if someone is adding a listener afterwards. Not sure how to do this in dojo.event.
Making this cleaner will eliminate a common source of bugs for people using Dojo Storage and make their code cleaner.