Skip to content

Commit

Permalink
Adds check preset for no network
Browse files Browse the repository at this point in the history
  • Loading branch information
wrousseau committed Dec 17, 2015
1 parent c2e8e22 commit a0c7896
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/services/angular-defensive.services.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import DefensiveConfiguration from './defensive-configuration';

var moduleName = 'ngDefensive.services';

angular.module(moduleName, [])
angular.module(moduleName, ['offline'])
.factory('DefensiveConfiguration', DefensiveConfiguration.factory);
.factory('CheckPreset', CheckPreset.factory);

export default moduleName;
19 changes: 19 additions & 0 deletions src/services/check-preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const CONNECTION_STATUS = new WeakMap();

class CheckPreset {

constructor(connectionStatus) {
CONNECTION_STATUS.set(this, connectionStatus);
}

noNetwork() {
return !connectionStatus.isOnline();
}

static factory(connectionStatus) {
return new CheckPreset(connectionStatus);
}

}

export default CheckPreset;

0 comments on commit a0c7896

Please sign in to comment.