Skip to content

Commit 12fca90

Browse files
committed
Release v0.4.5
1 parent d4bdbed commit 12fca90

File tree

4 files changed

+16
-39
lines changed

4 files changed

+16
-39
lines changed

README.md

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,12 @@ angular.module('myApp', ['emguo.poller']);
6666

6767
You can also use [cdnjs](https://cdnjs.com/libraries/angular-poller) files:
6868
```html
69-
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-poller/0.4.4/angular-poller.js"></script>
70-
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-poller/0.4.4/angular-poller.min.js"></script>
69+
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-poller/0.4.5/angular-poller.js"></script>
70+
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular-poller/0.4.5/angular-poller.min.js"></script>
7171
```
7272

7373
## Quick configuration
7474
```javascript
75-
// Inject angular poller service.
76-
var myModule = angular.module('myApp', ['emguo.poller']);
77-
7875
myModule.controller('myController', function($scope, $resource, poller) {
7976

8077
// Define your resource object.
@@ -103,9 +100,6 @@ myModule.controller('myController', function($scope, $resource, poller) {
103100

104101
### Customize $resource poller
105102
```javascript
106-
// Inject angular poller service.
107-
var myModule = angular.module('myApp', ['emguo.poller']);
108-
109103
myModule.controller('myController', function($scope, $resource, poller) {
110104

111105
// Define your resource object.
@@ -241,29 +235,25 @@ myPoller.promise.then(null, null, function(result) {
241235

242236
Alternatively you can use AngularJS `interceptors` for global error handling like so:
243237
```javascript
244-
angular.module('myApp', ['emguo.poller'])
245-
.config(function($httpProvider) {
246-
$httpProvider.interceptors.push(function($q, poller) {
247-
return {
248-
'responseError': function(rejection) {
249-
if (rejection.status === 503) {
250-
// Stop poller or provide visual feedback to the user etc
251-
poller.stopAll();
252-
}
253-
return $q.reject(rejection);
238+
myModule.config(function($httpProvider) {
239+
$httpProvider.interceptors.push(function($q, poller) {
240+
return {
241+
'responseError': function(rejection) {
242+
if (rejection.status === 503) {
243+
// Stop poller or provide visual feedback to the user etc
244+
poller.stopAll();
254245
}
255-
};
256-
});
246+
return $q.reject(rejection);
247+
}
248+
};
257249
});
250+
});
258251
```
259252

260253
You may also use `setErrorInterceptor` if you are using Restangular.
261254

262255
### Multiple pollers
263256
```javascript
264-
// Inject angular poller service.
265-
var myModule = angular.module('myApp', ['emguo.poller']);
266-
267257
myModule.controller('myController', function($scope, poller) {
268258

269259
var poller1 = poller.get(target1),
@@ -288,9 +278,6 @@ myModule.controller('myController', function($scope, poller) {
288278

289279
### Multiple controllers
290280
```javascript
291-
// Inject angular poller service.
292-
var myModule = angular.module('myApp', ['emguo.poller']);
293-
294281
myModule.factory('myTarget', function() {
295282
// return $resource object, Restangular object or $http url.
296283
return ...;
@@ -332,8 +319,6 @@ var myPoller = poller.get(myTarget, {
332319
You can also use `pollerConfig` to set `smart` globally for all pollers.
333320

334321
```javascript
335-
var myModule = angular.module('myApp', ['emguo.poller']);
336-
337322
myModule.config(function(pollerConfig) {
338323
pollerConfig.smart = true;
339324
});
@@ -348,8 +333,6 @@ But if you do want to have more than one poller running against the same target,
348333
poller on calling `poller.get` like so:
349334

350335
```javascript
351-
var myModule = angular.module('myApp', ['emguo.poller']);
352-
353336
myModule.config(function(pollerConfig) {
354337
pollerConfig.neverOverwrite = true;
355338
});
@@ -358,8 +341,6 @@ myModule.config(function(pollerConfig) {
358341
### Automatically stop all pollers when navigating between views
359342
In order to automatically stop all pollers when navigating between views with multiple controllers, you can use `pollerConfig`.
360343
```javascript
361-
var myModule = angular.module('myApp', ['emguo.poller']);
362-
363344
myModule.config(function(pollerConfig) {
364345
pollerConfig.stopOn = '$stateChangeStart'; // If you use ui-router.
365346
pollerConfig.stopOn = '$routeChangeStart'; // If you use ngRoute.
@@ -371,8 +352,6 @@ You also have the option to set `pollerConfig.stopOn` to `$stateChangeSuccess` o
371352
You can also use `pollerConfig` to automatically reset all pollers when navigating between views with multiple controllers.
372353
It empties poller registry in addition to stopping all pollers. It means `poller.get` will always create a new poller.
373354
```javascript
374-
var myModule = angular.module('myApp', ['emguo.poller']);
375-
376355
myModule.config(function(pollerConfig) {
377356
pollerConfig.resetOn = '$stateChangeStart'; // If you use ui-router.
378357
pollerConfig.resetOn = '$routeChangeStart'; // If you use ngRoute.
@@ -384,8 +363,6 @@ You also have the option to set `pollerConfig.resetOn` to `$stateChangeSuccess`
384363
Use the `handleVisibilityChange` option to automatically slow down poller delay to `idleDelay` when page is hidden.
385364
By default `idleDelay` is set to 10 seconds.
386365
```javascript
387-
var myModule = angular.module('myApp', ['emguo.poller']);
388-
389366
myModule.config(function(pollerConfig) {
390367
pollerConfig.handleVisibilityChange = true;
391368
});

angular-poller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Angular poller service. It uses a timer and sends requests every few seconds
66
* to keep the client synced with the server.
77
*
8-
* @version v0.4.4
8+
* @version v0.4.5
99
* @link http://github.com/emmaguo/angular-poller
1010
* @license MIT
1111
*

angular-poller.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-poller",
3-
"version": "0.4.4",
3+
"version": "0.4.5",
44
"description": "Lightweight poller service for AngularJS apps",
55
"main": "index.js",
66
"author": "Emma Guo <[email protected]>",

0 commit comments

Comments
 (0)