You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 20, 2018. It is now read-only.
I have a situation where I have multiple directives that subscribe to a stream from a service. If a directive is destroyed do I need to unsubscribe from the stream so I don't have zombie listeners? Or does it get garbage collected. If I need to unsubscribe how do I do it? newZoneStream.dispose(); is undefined.
/*** Directive ***/functionpanelController(rxService){varvm=this;//private variablesvarnewZoneStream=null;//public variablesvm.zones=null;//public functionsvm.init=init;vm.destroy=destroy;functioninit(){newZoneStream=rxService.getNewZoneStream();newZoneStream.subscribe(function(data){vm.zones=data;});}functiondestroy(){// DO I NEED TO DISPOSE HERE?: newZoneStream.dispose(); ?}}functionpanelLink(scope,element,link,ctrl){ctrl.init();scope.$on('$destroy',function(){ctrl.destroy();})}/*** Service ***/functiongetNewZoneStream(){if(!newZonesStream){newZonesStream=rx.Observable.create(function(observable){socket.on("new-zones",function(data){observable.onNext(data);});//clean up functionreturnfunction(){//$sails.off("new-zones");console.log("new zones stream closed");}});}returnnewZonesStream;}