Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Robertus Johansyah
    @kororo
    @analog-nico hi there, i stumbled upon ur fire-up module, quick question tho, how do I pass custom options for my DI module?
    Nicolai Kamenzky
    @analog-nico
    Hi @kororo do you mean like additional parameters injected into the module? This would be done with static arguments. Or do you mean something else?
    Robertus Johansyah
    @kororo
    @analog-nico thanks so much for getting back so quickly. hmmm. static args seems not fit into my needs. I pasted an example code, http://pastebin.com/aJBtQTb8
    @analog-nico, what I am trying to achieve, to pass on the {key: "value"} to Theme instance
    Nicolai Kamenzky
    @analog-nico

    @kororo I see, interesting example!

    Assume you wouldn't use fire-up. In just plain old node.js modules you would write:

    Nicolai Kamenzky
    @analog-nico

    @kororo

    // theme.js
    'use strict'
    
    let dep = require('dependency')
    
    function Theme(options) {
        console.log(options)
    }
    
    module.exports = Theme

    ...and instantiate it using:

    let Theme = require('theme.js')
    
    let theme = new Theme({ key: 'value' })

    With fire-up you can implement the same using:

    // theme.js
    'use strict'
    
    // Fire me up!
    module.exports = {
        implements: "Theme",
        inject: ['require(dependency)'],
        factory: function(dep) {
            return function Theme(options) {
                console.log(options)
            }
        }
    }

    ...and instantiate it using:

    fire_up('Theme').then(function (Theme) {
        let theme = new Theme({ key: 'value' })
    })
    @kororo I interpreted your use case a little loosely. I hope this is what you intent to do.
    Robertus Johansyah
    @kororo
    @analog-nico AHA! I forgot you could pass the class reference back to the caller and let the caller to pass the options to the class
    that is actually one option that I could have
    thanks on the very detail explanation + example
    Robertus Johansyah
    @kororo
    I will give a shot
    Nicolai Kamenzky
    @analog-nico
    @kororo You are welcome! Feel free to ping me if you have more questions.
    Robertus Johansyah
    @kororo
    @analog-nico thanks!!