Giter Site home page Giter Site logo

appolo-inject's People

Contributors

antonzy avatar shmoop207 avatar uditalias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

appolo-inject's Issues

Problem with default exports

Say I have a module like this:

export default class M {
}

and I have a definition for this like below:
{
path: "./M",
singleton: true,
lazy: true
}

I get an exception from inject.js saying object is not a function. I tried forking your library and changing the code to this:

       try {
            //crate object instance
            if (typeof objectDefinition.type === 'object') {
                objectDefinition.type = objectDefinition.type.default;
            }
            newObjectInstance = new objectDefinition.type(...argumentInstances);            
        }
        catch (e) {
            throw new Error("Injector failed to create object objectID:" + objectID + "' \n" + e);
        }

This way it works, not sure if I could achieve this without modifying your lib?

Thanks.

Problem with using inject with "new" that needs params in constructer

I know I can use inject to get a "new" instance when the class isn't defined with singleton:true
BUT: How can I use inject with a class that needs params in the constructor (in the new process)?

for example:

var AlertBase = Class.define({
    $config: {
        name: 'AlertBase'

    },
    constructor: function (warningMessage, receipents) {
        this.message = warningMessage;
        this.receipents = receipents;
    }
});

var SpecificsAlert = AlertBase.define({
    $config: {
        id: 'SpecificsAlert',
        name: 'SpecificsAlert',
        extends: AlertBase,
        alias: ['alert']
    },

    constructor: function (receipents, envName) {
        var warningMessage = 'WARNING --!';

        var payload = {
            environment: envName
        };
        this.callParent(warningMessage, receipents);

    }
});

How can I use inject for the SpecificsAlert class and pass it the expected params for the constructor?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.