Nicole
Nicole

Reputation: 33227

What's the conventional directory for classes in an Ember project?

If I create a custom class according to https://guides.emberjs.com/release/object-model/classes-and-instances/,

e.g.

// person.js
import EmberObject from '@ember/object';

const Person = EmberObject.extend({
  say(thing) {
    alert(thing);
  }
});

Is there a conventional directory in the ember project for person.js?

None of these conventional directories seem quite right...

Upvotes: 2

Views: 246

Answers (1)

atomkirk
atomkirk

Reputation: 3801

Definitely utils. Utils is for anything that does not fit into any of the core ember categories.

Another way to think about it is, if you always have to import it to use it rather than letting the resolver load it, it should be in utils. There are lots of exceptions to this, like inheriting from things and using mixins, but as a general rule its a good starting point when thinking about what should be in utils.

From the docs:

Ember utilities are reusable code that can be accessed from various parts of the application.

https://guides.emberjs.com/release/tutorial/service/

I wouldn't call utils "too" generic. Your class sounds like something that will be reused in various parts of the application.

Upvotes: 3

Related Questions