pagedown icon indicating copy to clipboard operation
pagedown copied to clipboard

Support asynchronous module definition

Open GoogleCodeExporter opened this issue 10 years ago • 2 comments

Supporting asynchronous module definition [1] would allow to use 
CommonJS-compliant asynchronous javascript loaders like requirejs [2] on the 
client side.

This also allows to declare dependencies between modules, and to ensure that 
some module is loaded before an other.

This would look like this for Markdown.Converter:

``` Javascript
define(function() {
    // return Converter here
});

And for Markdown.Editor:

define(['Markdown.Converter'], function(Converter) {
    // return Editor here
});

And in the client code:

require(['Markdown.Converter', 'Markdown.Editor'], function(Converter, Editor) {
     // ...
});

With non-CommonJs compat:

var Markdown;

function doExport(factory) {
    if (typeof 'define' === 'function' && typeof 'require' === 'function') {
        define.call(this, factory);
    } else {
        Markdown.Converter = factory();
    }
}
doExport(function() {
     // ... return Converter
});

[1] http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition [2] http://requirejs.org/


Original issue reported on code.google.com by `arnaud.lb` on 4 Aug 2011 at 5:09

GoogleCodeExporter avatar Sep 12 '15 05:09 GoogleCodeExporter

I was somewhat expecting this request :)

I'll look at it.

Original comment by [email protected] on 5 Aug 2011 at 5:30

  • Changed state: Accepted
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

GoogleCodeExporter avatar Sep 12 '15 05:09 GoogleCodeExporter

This would be great for using pagedown in GitHub's gollum software.

Original comment by [email protected] on 7 Jun 2012 at 4:32

GoogleCodeExporter avatar Sep 12 '15 05:09 GoogleCodeExporter