Nautical Poseidon Mythology

    simple-amd
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.4 • Public • Published

    simple-amd

    AMD loader for isolated module environment

    Motivation

    If you need some module system which does not touch anything in your desk, this would be a good choice.

    Compared with r.js, our loader provides following things

    • Isolated loader system
      r.js declares shared module system, so it cannot hide some of your module from others.
    • In-house loader plugin we're trying to make simple-amd to use r.js loader plugins, additionally some loader plugins are included that helps to get data from pouchdb. we also welcome plugin suggestion, please file an issue if needed.

    Usage

    const Loader = require('simple-amd').Loader;
    const React = require('react'); // module to be exposed to your module system.
     
    const loader = new Loader({});
    loader.define('react', [], () => React);
    loader.require('react', (React) => { ... });

    To use loader with default plugins, use default-loader

    const PouchDB = require('PouchDB');
    const React = require('react');
    const ReactDOM = require('react-dom');
     
    const create_loader = require('simple-amd/lib/default-loader').create_loader;
    const db = new PouchDB(YOUR_HOST);
     
    const loader = create_loader(db, {
      react: React
    });
    loader.require(['attachment!docId#attachmentId', 'doc!docId'], function(attachment, observableDoc) {
      observableDoc.subscribe(data => {
        // it will render react 'reactive'
        ReactDOM.render(React.createElement(attachment.SomeModule), { data: data });
      });
    });

    Install

    npm i simple-amd

    DownloadsWeekly Downloads

    9

    Version

    0.2.4

    License

    MIT

    Last publish

    Collaborators

    • blmarket