How to use the di.js/build/di.es5.createContainer function in di

To help you get started, we’ve selected a few di examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github malankajs / malanka / example / index.js View on Github external
if (data[id]) {
            return Module.restore(data[id], dependencies);
        }
    }
};

diConfig.factories = [
    createRestoreFactory(diData),
    createMethodFactory(),
    createInstanceFactory()
];

diConfig.resolvers.push(staticResolver({FetchRequest}));
diConfig.dependencies.request = 'FetchRequest';

let di = createContainer(diConfig);

di.put('renderer', new DomRenderer());

then(di({'env': 'env', router: 'router'}, {di}), ({env, router}) => {
    return router.start().then(event => {
        env.render(event.page, document.body.firstChild);
    });
});
github malankajs / malanka / example / server / controllers / serverRender.js View on Github external
export function serverRender(req, res, next) {
    let di = createContainer(diConfig);

    di.put('renderer', new StringRenderer());
    Promise.resolve(di({router: 'router', 'env': 'env'}, {di}))
        .then(({router, env}) => {
            return router.match(req.url).then(({page}) => {
                return env.render(page)
            });
        })
        .then(body => {
            let definitions = di.getDefinitions(),
                promises = [];

            Object.keys(definitions).forEach(key => {
                let {instance} = definitions[key];

                if (instance && instance.async) {