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
* String ID system for trackers removed, now use instances created with `var myTrack = new promiseTracker([options]);`.
7
+
* http interceptor functionality is now optional; use it by including `promise-tracker-http-interceptor.js`
8
+
* maxDuration option is removed (there are better ways to do this in every case)
27
9
28
-
* A promiseTracker instance can no longer be created with the
29
-
`promiseTracker` function, it is a getter only now. Use
30
-
`promiseTracker.register()`.
10
+
If you are using 1.x in your app and you would like to upgrade, here is the migration guide:
31
11
32
-
To migrate your code, change the following:
33
-
34
-
```js
35
-
var newTracker =promiseTracker('newTracker', options);
36
-
//..later
37
-
var tracker =promiseTracker('newTracker');
38
-
```
39
-
40
-
To:
41
-
42
-
```js
43
-
var newTracker =promiseTracker.register('newTracker', options);
44
-
//..later
45
-
var tracker =promiseTracker('newTracker');
46
-
```
12
+
* Find your string ids where you are getting promiseTracker with `promiseTracker('id')`, and create a reference instead with `promiseTracker()`. If you want a global tracker, store it on rootScope or in a service (check README).
13
+
* (note: The actual instances of the promiseTrackers will have the same API).
Copy file name to clipboardExpand all lines: README.md
+42-35Lines changed: 42 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,10 @@
1
1
angular-promise-tracker
2
2
=======================
3
3
4
+
> **Version**: 2.0
5
+
6
+
(note to users using version 1.x: upgrading has *many* breaking changes, see [the CHANGELOG](https://github.com/ajoslin/angular-promise-tracker/tree/master/CHANGELOG.md).)
Registers a new promiseTracker with the given identifier.
73
+
Creates and returns a new promiseTracker.
66
74
67
75
Options can be given as an object, with the following allowed values:
68
76
69
77
-`activationDelay``{Number}` - Number of milliseconds that an added promise needs to be pending before this tracker is active.
70
78
* Usage example: You have some http calls that sometimes return too quickly for a loading spinner to look good. You only want to show the tracker if a promise is pending for over 500ms. You put `{activationDelay: 500}` in options.
71
79
-`minDuration``{Number}` - Minimum number of milliseconds that a tracker will stay active.
72
80
* Usage example: You want a loading spinner to always show up for at least 750ms. You put `{minDuration: 750}` in options.
73
-
-`maxDuration``{Number}` - Maximum number of milliseconds that a tracker will stay active.
74
-
* Usage example: Your http request takes over ten seconds to come back. You don't want to display a loading spinner that long; only for two seconds. You put `{maxDuration: 2000}` in options.
75
-
76
-
***`void` promiseTracker.deregister(trackerId)**
77
81
78
-
Deregisters a tracker `register`ed with the given identifier.
79
-
80
-
***`tracker` promiseTracker(trackerId)**
81
-
82
-
Returns a tracker with `register`ed with the given id.
83
-
84
-
### **`$http` Sugar**
85
-
86
-
***Any $http call's `config` parameter can have a `tracker` field. Examples:**
82
+
Often you want a global promiseTracker (eg to show a loading screen); one easy way is to put the tracker on your $rootScope:
87
83
88
84
```js
89
-
//Add $http promise to tracker with id 'myTracker'
90
-
$http('/banana', { tracker:'myTracker' })
91
-
```
92
-
```js
93
-
//Add $http promise to both 'tracker1' and 'tracker2'
0 commit comments