Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Short syntax #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Short syntax #13

wants to merge 2 commits into from

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