Skip to content

Short syntax#13

Open
matjaz wants to merge 2 commits intovojtajina:masterfrom
matjaz:short-syntax
Open

Short syntax#13
matjaz wants to merge 2 commits intovojtajina:masterfrom
matjaz:short-syntax

Conversation

@matjaz
Copy link
Contributor

@matjaz matjaz commented Apr 6, 2014

instead of writing

var module = {
  car: ['type', Car],
  power: ['value', 1184]
}

you simply write

var module = {
  car: di.type(Car),
  power: 1184
}

matjaz added 2 commits April 6, 2014 11:04
instead of writing

var module = {
  car: ['type', Car],
  power: ['value', 1184]
}

you simply write

var module = {
  car: di.type(Car),
  power: 1184
}
@vojtajina
Copy link
Owner

The main reason for the current kind of ugly string syntax was that you don't have to include DI in order to define a module. So I'm not sure if this is worthy (even though it is a nicer)...

@matjaz
Copy link
Contributor Author

matjaz commented Apr 28, 2014

that's true, but using module in this syntax is specific to node-di. For example to access Car you have to write

module.car[1]

which is a bit cumbersome and lib specific.

@matjaz
Copy link
Contributor Author

matjaz commented Apr 28, 2014

alternatively (what di.type() does is):

Car.$type = 'type';
var module = {
  car: Car,
  power: 1184
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants