Last active
          May 30, 2016 21:27 
        
      - 
      
- 
        Save katowulf/9073ad8ea56281e0de6d to your computer and use it in GitHub Desktop. 
    Overriding error handling in AngularFire by extending and decorating $$error
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // this will remove all error logging globally | |
| angular.config(function($provide) { | |
| $provide.decorator("$firebaseObject", function($delegate) { | |
| $delegate.prototype.$$error = function(err) { | |
| this.$destroy(err); | |
| }; | |
| return $delegate; | |
| }); | |
| $provide.decorator("$firebaseArray", function($delegate) { | |
| $delegate.prototype.$$error = function(err) { | |
| this.$destroy(err); | |
| }; | |
| return $delegate; | |
| }); | |
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // this will modify error handling for a single instance | |
| angular.service('ArrayWithSuppressedErrors', function($firebaseArray) { | |
| var ArrayService = $firebaseArray.$extend({ | |
| $$error: function(err) { | |
| this.$destroy(err); | |
| } | |
| }); | |
| return function(ref) { | |
| return new ArrayService(ref); | |
| } | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment