mami
This is the one who cares about your dependencies.
Last updated 2 years ago by jmas .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mami 
SYNC missed versions from official npm registry.

Mami

This is the one who cares about your dependencies.

Example

import mami from 'mami';

const get = mami({
    loadModule: moduleName => import(`./modules/${moduleName}`).then(exports => exports['default']),
    modules: {
        dispatcher: load => load('dispatcher'),
        views: load => load('views'),
        router: load => load('router'),
        app: {
            dispatcher: get => get('dispatcher'),
            views: get => get('views').then(views => views({
                globals: {
                    appName: 'Welcome'
                }
            })),
            router: get => get('router'),
        }
    }
});

get('app').then(app => app.render(document.body));

API

mami(options: Object): Function

Option name Description
loadModule: Function Function that load modules. It should return Promise that should return loaded module content.
modules: Object Keys of that object is a module name (any word). Values is a object or function that tell mami what dependencies is required.

Returns function that give you ability to get any described module.

const get = mami({
    loadModule,
    modules: {
        a: load => load('my_a')
    }
});
get('a') // returns Promise
    .then(aModuleContent => {
        console.log(aModuleContent);
    })
    .catch(error => console.log(error));

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

1 Versions

  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |