Thank you for your guidance Eric. I am still a bit confused though. To my understanding, the .toRx().subscribe( ... ) function is meant to RECEIVE messages and the .next() function is meant to BROADCAST messages
In this plnkr ( http://plnkr.co/edit/MT3xOB?p=info <http://www.google.com/url?q=http%3A%2F%2Fplnkr.co%2Fedit%2FMT3xOB%3Fp%3Dinfo&sa=D&sntz=1&usg=AFQjCNHiZitmhYQrzYIUvX6AwZCREE2Wlw> ) , you invoke the .toRx().subscribe( ... ) function from a *data* object that seems to be defined/derived originally from the template: @Component({ > selector : 'child-cmp', > template : '', > inputs : ['data'] > }) > class ChildCmp { > afterViewInit() { > this.data.toRx().subscribe((data) => { > console.log('New data has arrived!', data); > }); > } > } In this plnkr ( http://plnkr.co/edit/rNdInA?p=preview <http://www.google.com/url?q=http%3A%2F%2Fplnkr.co%2Fedit%2FrNdInA%3Fp%3Dpreview&sa=D&sntz=1&usg=AFQjCNGxJ0s5V27UUjy1TOmhlWcLG_tNJQ> ) , you invoke the .toRx().subscribe( ... ) function from an *evt* object and its *emitter* function (originating from Service injected into the component's constructor) @Component({ > selector : 'parent-cmp', > template : '' > }) > class ParentCmp { > constructor(evt: EventService) { > evt.emitter.subscribe((data) => > console.log("I'm the parent cmp and I got this data", data)); > } > } Is is possible for the BROADCAST to take place in a function of the Service itself while at the same time, is it possible for the Component to RECEIVE the message without relying upon a returned Service object or Template data object to chain its .toRX().subscribe( ... ) function invokation? import {Injectable, EventEmitter} from 'angular2/angular2'; > @Injectable() > export class DataService { > items:Array<any>; > dispatcher: EventEmitter = new EventEmitter(); > constructor() { > this.items = [ > { name: 'AAAA' }, > { name: 'BBBB' }, > { name: 'CCCC' } > ]; > } > getItems() { > return this.items; > } > sendItems() { > this.dispatcher.next( this.items ); > } > } > export var DATA_BINDINGS: Array<any> = [ > DataService > ]; @Component({ > selector: 'rabble' > }) > @View({ > ... > }) > export class Rabble { > > items : Array<any>; > > constructor( public dataService : DataService) { > > console.log('this.routeParam', this.dataService.getItems()); > } > > afterViewInit() { > this.data.toRx().subscribe((data) => { > console.log('New data has arrived!', data); > }); > } > > handleClick() { > this.dataService.sendItems(); > } > } Also, what is the correct EventEmitter syntax to use to subscribe to a particular "channel" as we did in angular 1 $Broadcast and $on? $scope.$broadcast('myCustomEvent', { someProp: 'Sending you an Object!' // send whatever you want}); $scope.$on('myCustomEvent', function (event, data) { console.log(data); // 'Data to send'}); -- 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.
