|
1 | 1 | import State from './State';
|
2 | 2 |
|
3 |
| -var DownloadPausedState = function(oDownload) |
4 |
| -{ |
5 |
| - State.apply(this); |
6 |
| - this.oDownload = oDownload; |
7 |
| -}; |
8 |
| -DownloadPausedState.prototype = new State(); |
9 |
| -DownloadPausedState.prototype.download = function(){ |
10 |
| - this.oDownload.setState(this.oDownload.getDownloadingState()); |
11 |
| - console.log("Continue Download!"); |
12 |
| -}; |
13 |
| -DownloadPausedState.prototype.pause = function(){ |
14 |
| - throw new Error("You can't pause a paused download!"); |
15 |
| -}; |
16 |
| -DownloadPausedState.prototype.fail = function(){ |
17 |
| - this.oDownload.setState(this.oDownload.getDownloadedFailedState()); |
18 |
| - console.log("Download has failed!"); |
19 |
| -}; |
20 |
| -DownloadPausedState.prototype.finish = function(){ |
21 |
| - this.oDownload.setState(this.oDownload.getDownloadedState()); |
22 |
| - console.log("Download has finished!"); |
23 |
| -}; |
| 3 | +class DownloadPausedState extends State { |
| 4 | + constructor(download) { |
| 5 | + super(); |
| 6 | + this._download = download; |
| 7 | + } |
| 8 | + |
| 9 | + download() { |
| 10 | + this._download.setState(this._download.getDownloadingState()); |
| 11 | + console.log("Continue Download!"); |
| 12 | + } |
| 13 | + |
| 14 | + pause() { |
| 15 | + throw new Error("You can't pause a paused download!"); |
| 16 | + } |
| 17 | + |
| 18 | + fail() { |
| 19 | + this._download.setState(this._download.getDownloadedFailedState()); |
| 20 | + console.log("Download has failed!"); |
| 21 | + } |
| 22 | + |
| 23 | + finish() { |
| 24 | + this._download.setState(this._download.getDownloadedState()); |
| 25 | + console.log("Download has finished!"); |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +export default DownloadPausedState; |
0 commit comments