As a java developer, and speaking in java lingo, I want to create a Event
Service class, for handling event / message passing queue, and I want to
create a factory to generate instances of my Message Service class.
--- Now back to angular ---
I want to be able to have an angular-app-wise instance of my message
service, and I want modules to be able to create instance for their own use
if they so desire.
Being newish to js and angular, I've come up with about 100 different ways
with services and prototypes and stuff, and I just can't figure out whats
the best approach.
How do you guys feel about this approach?
angular.module('EventServiceModule', [])
.factory('EventService', function() {
var EventService = function() {
this.eventHandlers = {};
};
EventService.prototype.sendEvent = function(eventId, data) {};
EventService.prototype.registerEventHandler = function(eventId,
handler) {};
return EventService;
})
.factory('SystemEventService', function(EventService) {
var es = new EventService();
return es;
});
Then people can use the SystemEventService if they want, or create a new
EventService instance the same way I did, if they want their own instance
of it.
Thanks,
Brian
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.