Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 29 2015 17:12
    stephanos closed #12
  • Jul 29 2015 17:12
    stephanos commented #12
  • Jul 29 2015 17:03
    sergiolepore commented #12
  • Jul 27 2015 18:34
    stephanos commented #12
  • Jul 27 2015 16:09
    stephanos commented #12
  • Jul 27 2015 13:34
    sergiolepore commented #12
  • Jul 27 2015 12:55
    sergiolepore commented #11
  • Jul 26 2015 08:41
    stephanos opened #12
  • Jul 26 2015 08:12
    stephanos commented #11
  • Jul 22 2015 13:43
    sergiolepore closed #8
  • Jul 22 2015 13:43
    sergiolepore commented #8
  • Jul 22 2015 13:40
    sergiolepore closed #11
  • Jul 22 2015 13:40
    sergiolepore commented #11
  • Jul 13 2015 13:42
    sergiolepore commented #11
  • Jul 07 2015 14:43
    sergiolepore commented #11
  • Jul 07 2015 12:46
    stephanos opened #11
  • Apr 28 2015 02:36

    sergiolepore on dependency-upgrades

    (compare)

  • Apr 28 2015 01:56
    Travis sergiolepore/Cation (v2.3.0) passed (89)
  • Apr 28 2015 01:55
    Travis sergiolepore/Cation (master) passed (88)
  • Apr 28 2015 01:54

    sergiolepore on v2.3.0

    (compare)

Gonçalo Margalho
@DevAlien
@sergiolepore Hi, do you know if this is used by anyone except you? Or if it's used in a production env?
Sergio Lepore
@sergiolepore
@DevAlien hi! The v1 started as a requirement for an old, old project. This new version (currently v2.1.2) is used in a new project for a client of mine. It's really stable and fast, and will be locked in production in a few months (April, 2015).
You can check the 'tests/' directory and see if any feature suits your needs :smile:
Gonçalo Margalho
@DevAlien
@sergiolepore thanks, I will check it and see if it suits my needs.
Sergio Lepore
@sergiolepore
@DevAlien you're welcome :smile:
Romain E Silva
@resilva
Hi! I'm testing Cation and I would like to know if we can load the same container from multiple files. I've tested this :
Romain E Silva
@resilva

Sorry @sergiolepore my message was cut, this is the files that i've used for my tests :
index.js

var Cation    = require('cation')
var container = new Cation()
var Atom      = function() { /* Atom service! */ }
container.register('Atom', Atom);

var Blah = require('./blah');

blah.js

var Cation    = require('cation')
var container = new Cation()

container.get('Atom').then(function(A) {
    console.log(A);
});

I've probably misunderstood something ?

Sergio Lepore
@sergiolepore
Oh my... Sorry for replying you so late @resilva :(
In order to keep the container instance across files, you'll need to expose the instance
Each time you require Cation and do new Cation(), you are creating a completely new container
Romain E Silva
@resilva

Ok thanks for your reply :) so I could make another file with the cation instance to share it with another modules ? Still we can set an id to a cation instance can we get the instance directly instead of creating a new one ? For example :

index.js

var Cation = require('cation')
var container = new Cation({id: 'blah'})
var Atom = function() { /* Atom service! */ }
container.register('Atom', Atom)

var Blah = require('./blah');

blah.js

var Cation = require('cation')
var container = new Cation({id: 'blah'});

container.get('Atom').then(function(A) {
  console.log(A)
})
Sergio Lepore
@sergiolepore
@resilva no. You have to export the instance with the module and then require it wherever you need it :)
The container ID is part of a new (but not yet production-ready) feature to handle subcontainers
// dependencies.js
var Cation = require('cation')
var container = new Cation()

container.register('something-initial', 'Hello World', { type: 'static' })

module.exports = exports = container
Sergio Lepore
@sergiolepore
// b.js
var container = require('dependencies.js')
container.get('something-initial').then(function(value) {
  console.log(value) // Hello World
})
This kind of Singleton behavior using modules is possible thanks to Node's module caching
Romain E Silva
@resilva
sorry for the late reply @sergiolepore thanks for your advices, at the beginning I was thinking of using the Node's module caching for getting a cation instance, but doesn't think of using it like that my bad and thanks again !
Sergio Lepore
@sergiolepore
@resilva you're welcome! :smile:
Romain E Silva
@resilva
@sergiolepore I've another question (yes again :) !) what did you think about a parameter feature for cation like the parameters that can be set with Sf2, have you think about an implementation or think about another way to use them ? Thanks :)
Sergio Lepore
@sergiolepore
@resilva hey! You can use a static resource: https://github.com/sergiolepore/Cation/#static-resources
Romain E Silva
@resilva
Oh god I'm feeling very silly to nit think about static resources ... Thanks for pointing me that solution!
Sergio Lepore
@sergiolepore
@resilva :)