How to properly implement global classes


#1

I have a component for displaying a list of field inputs. The component itself as well as each field should be able to validate the data it receives from the user.

This would require an instance to a global Validator class that can be accessed from anywhere.

Is this as simple as globally declaring some like: Spark.Validator = Ember.Object.extend({ …make object }); var Validator = Spark.Validator.create();

Is that the ember way?


#2

What you’re looking for is Ember’s dependency injection. Look in the guides


#3

Could you be a little more specific. There’s a lot of information in the guides. Link maybe?


#4

Here’s dependency injection.