Skip to content
This repository has been archived by the owner on May 16, 2021. It is now read-only.

Commit

Permalink
Merge branch 'graphDestroy' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnny committed Feb 21, 2016
2 parents a2789d3 + 019f8f7 commit 8d15c9f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

10 changes: 9 additions & 1 deletion dst/ngCytoscape.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
cy.ready(function() {
cytoData.setGraph(cy, attrs.id);
});
scope.$on('$destroy', function(){
cy.destroy();
cytoData.unresolveGraph(attrs.id)
})

}
}
Expand Down Expand Up @@ -244,6 +248,11 @@
_private.Graph = {};
var self = this;

self.unresolveGraph = function(graphId){
var id = cytoHelpers.obtainEffectiveGraphId(_private.Graph, graphId);
_private['Graph'][id] = undefined;
};

self.setGraph = function(gObject, scopeId) {
var defer = getUnresolvedDefer(_private.Graph, scopeId);
defer.resolve(gObject);
Expand Down Expand Up @@ -280,7 +289,6 @@
graph.remove(graph.elements());
return;
}
//Add All Elements
if(graph.elements().length === 0){
angular.forEach(newEles, function(ele,index){
if(isValidElement(ele,index)){
Expand Down
2 changes: 1 addition & 1 deletion dst/ngCytoscape.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/directives/cytoscape-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
cy.ready(function() {
cytoData.setGraph(cy, attrs.id);
});
scope.$on('$destroy', function(){
cy.destroy();
cytoData.unresolveGraph(attrs.id)
})

}
}
Expand Down
5 changes: 5 additions & 0 deletions src/services/cytoData.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
_private.Graph = {};
var self = this;

self.unresolveGraph = function(graphId){
var id = cytoHelpers.obtainEffectiveGraphId(_private.Graph, graphId);
_private['Graph'][id] = undefined;
};

self.setGraph = function(gObject, scopeId) {
var defer = getUnresolvedDefer(_private.Graph, scopeId);
defer.resolve(gObject);
Expand Down

0 comments on commit 8d15c9f

Please sign in to comment.