Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apendua/meteor-amd-manager
A simple utility class for creating AMD module managers
https://github.com/apendua/meteor-amd-manager
Last synced: 20 days ago
JSON representation
A simple utility class for creating AMD module managers
- Host: GitHub
- URL: https://github.com/apendua/meteor-amd-manager
- Owner: apendua
- License: mit
- Created: 2014-07-26T12:06:47.000Z (over 10 years ago)
- Default Branch: develop
- Last Pushed: 2015-09-28T09:41:22.000Z (about 9 years ago)
- Last Synced: 2024-10-09T09:33:53.275Z (about 1 month ago)
- Language: JavaScript
- Size: 301 KB
- Stars: 7
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Notes for Meteor 0.9.x
This package is now called `amd:manager`.
# meteor-amd-manager [![Circle CI](https://circleci.com/gh/apendua/meteor-amd-manager.svg?style=svg)](https://circleci.com/gh/apendua/meteor-amd-manager)
This package provides `AMDManager` class that allows you to implement your own `define/require` module management routines.
## Installation
Simply type
```
meteor add amd:manager
```
and you're good to go.## Usage
As an example, lets implement the standard `define/reqire` pair. This could be done more like this:
```javascript
var manager = new AMDManager(),require = function (listOrName, body) {
var readyDep, isReady;
if (_.isFunction(body)) {
if (!_.isArray(listOrName)) {
listOrName = [listOrName, ];
}
return manager.require(listOrName, body);
} if (_.isString(listOrName)) {
return manager.get(listOrName);
}
throw new Error('Wrong parameters for require.');
}define = function (name, deps, body) {
if (arguments.length == 2) {
body = deps; deps = [];
}
manager.define(name, deps, body);
}define.amd = {};
```## Methods
The only non-obvious methods of the manager are:
* `onModuleNotFound` which allows you to define a callback to be called every time should the user request a
module that has not been defined yet. You can use it to decide if there is a need to download additional source
code from the server.
* `onModuleAlreadyDefined` which is called when a module is trying to be defined with the same name as an already
defined module. You can use it to display a warning or throw an error.