Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#16727 closed enhancement (wontfix)

Add AMD loader micro API event 'moduleLoaded'

Reported by: danwallie Owned by: Rawld Gill
Priority: undecided Milestone: tbd
Component: Loader Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:

Description

Add this line to the end of finishExec() in dojo.js (line 1174):

signal("moduleLoaded", [module.result, module.mid]);

By adding this event to the end of finishExec(), developers will be able to subscribe to notifications when individual modules are loaded. This need arose specifically so I would be able to tag modules with their id's using module.prototype for id-based routing and activation.

See

Change History (3)

comment:1 Changed 6 years ago by Rawld Gill

Resolution: wontfix
Status: newclosed

This is not part of the AMD spec. I also don't understand your use case (that's not a judgement as to its value, but rather that I don't have enough information). I'm (we are) very skeptical of adding new features to the loader that are not in the AMD standard unless there is a clear and important use case.

I would prefer you bring this up on the AMD mailing list. If you think this is really important for dojo, please provide further justification for the proposed extension.

comment:2 Changed 6 years ago by danwallie

I posted here about this:

http://dojo-toolkit.33424.n3.nabble.com/AMD-loader-module-specific-event-tt3995261.html;cid=1364236786172-513

Is there another more appropriate place to discuss?

comment:3 Changed 6 years ago by danwallie

I think I have the wrong mailing list. Nobody seems to be talking about AMD there. Can you please point me to the right one?

I cam also provide some more information here on the use case. I am using a different web framework, Durandal.js, to handle MVC type composition and routing. This framework needs to be able to load AMD modules as models for views, and it uses a string property to tag the modules so a view's model can be located by convention (i.e. an abstraction). The tag is applied to the module's prototype when the loader has finished loading the module. In require.js, this is accomplished via the semi-private onModuleLoad API, documented here:

https://github.com/jrburke/requirejs/wiki/Internal-API:-onResourceLoad

I believe that this event is important for making dojo compatible with these types of frameworks.

Thanks!

Note: See TracTickets for help on using tickets.