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

Clarification on importing vs. injecting #168

Open
ndarilek opened this issue Mar 29, 2016 · 5 comments
Open

Clarification on importing vs. injecting #168

ndarilek opened this issue Mar 29, 2016 · 5 comments

Comments

@ndarilek
Copy link

It would be nice if the spec could clarify when a thing should be injected vs. imported.

For instance, the context in the blog sample injects the Collections object it imports, but I've been importing it throughout my own app. Similarly, Meteor is injected into the context. I don't understand why it isn't imported instead. If it substantially saved on code then I'd get it, but both are a single line.

I recently refactored an app to Mantra, and every time I modularized a piece of code I wondered whether to import it each time I used it, or inject it into my context. It makes sense for a global like state, subs-manager or the like where you're creating an instance, but why Collections/Meteor?

@arunoda
Copy link
Collaborator

arunoda commented Mar 30, 2016

Okay. Here's the thing.

Every related to Meteor packages should be injected via the context. Basically, anything including collections.

That's only for the client.

In server, you can import them. Since there is no something called context in the server.

@fermuch
Copy link

fermuch commented Mar 30, 2016

Why is that? With Meteor 1.3 you can simply import a package from Meteor. Isn't it better to have an explicit import than a global dependency in the context?

@arunoda
Copy link
Collaborator

arunoda commented Mar 30, 2016

@fermuch yes that's true. But importing everything makes the project into un-maintainable state. (Yeah! In know, we can argue)

There are things we import like components and containers. Specially for anything in Meteor packages we do not import them inside in the context.

We do it for better testing isolating Meteor specific things into a single file. Trust me, Meteor packages will die sooner or later. That's why we built mantra in the first place.

@ndarilek
Copy link
Author

ndarilek commented Mar 30, 2016 via email

@fermuch
Copy link

fermuch commented Mar 30, 2016

Ah, I see. I wasn't thinking about testing, and you are right.
Testing while importing something from meteor is hard, really hard.
Importing only NPM is a lot easier.

I am with you with this issue, @arunoda.

Em 30-03-2016 08:44, Arunoda Susiripala escreveu:

@fermuch https://github.com/fermuch yes that's true. But importing
everything makes the project into un-maintainable state. (Yeah! In
know, we can argue)

There are things we import like components and containers. Specially
for anything in Meteor packages we do not import them inside in the
context.

We do it for better testing isolating Meteor specific things into a
single file. Trust me, Meteor packages will die sooner or later.
That's why we built mantra in the first place.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#168 (comment)

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

No branches or pull requests

3 participants