Skip to content

Commit

Permalink
Merge pull request #59 from basil79/prepare-3rd-party
Browse files Browse the repository at this point in the history
comments, docs
  • Loading branch information
basil79 authored Aug 24, 2022
2 parents 19e6823 + 75beb45 commit 9e50fce
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ adsManager.addEventListener('AdsManagerLoaded', function() {
// AdError
adsManager.addEventListener('AdError', function(adError) {
if(adsManager) {
// abort anything that currenlty doing on with AdsManager
// and reset to a default state
// Removes ad assets loaded at runtime that need to be properly removed at the time of ad completion
// and stops the ad and all tracking.
adsManager.abort();
}
// ...
Expand Down
15 changes: 14 additions & 1 deletion docs/ADSMANAGER.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
- [getRemainingTime](#getremainingtime-number)
- [getVolume](#getvolume-number)
- [setVolume](#setvolumevolume)
- [abort](#abort)
- [destroy](#destroy)
- [isDestroyed](#isDestroyed)
- [Events](#events)


Expand Down Expand Up @@ -176,10 +178,21 @@ Set the volume for the current ad.

- **`volume: Number`** - The volume to set, from `0` (muted) to `1` (loudest).

### destroy()
### abort()

Removes ad assets loaded at runtime that need to be properly removed at the time of ad completion and stops the ad and all tracking.

### destroy()

Cleans up the internal state, abort anything that is currently doing on with the `AdsManager` and reset to a default state.

### isDestroyed()

Returns `true` if destroyed.

#### Returns

- **`Boolean`**


## Events
Expand Down
4 changes: 2 additions & 2 deletions public/js/ads-manager.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
appendEvent('AdError : ' + adError);

if(adsManager) {
// abort anything that currenlty doing on with AdsManager
// and reset to a default state
// Removes ad assets loaded at runtime that need to be properly removed at the time of ad completion
// and stops the ad and all tracking.
adsManager.abort();
}

Expand Down
13 changes: 8 additions & 5 deletions src/ads-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1012,20 +1012,20 @@ AdsManager.prototype.abort = function(reCreateSlot = true) {
return;
}

// abort anything that is currently doing on with the AdsManager
// and reset to a default state
// Removes ad assets loaded at runtime that need to be properly removed at the time of ad completion
// and stops the ad and all tracking.

// stop and clear timeouts, intervals
// Stop and clear timeouts, intervals
this.stopVASTMediaLoadTimeout();
this.stopVPAIDProgress();

if(this._isVPAID) {
// unsubscribe for VPAID events
// Unsubscribe for VPAID events
this.removeCallbacksForCreative(this._creativeEventCallbacks);
this.removeCreativeAsset();
}

// reset global variables to default values
// Reset global variables to default values
this._nextQuartileIndex = 0;

this._isVPAID = false;
Expand Down Expand Up @@ -1056,6 +1056,9 @@ AdsManager.prototype.destroy = function() {
return;
}

// Cleans up the internal state, abort anything that is currently doing on with the AdsManager
// and reset to a default state.

// Reset the internal state of AdsManager
this.abort(false);
// Remove event listeners
Expand Down

0 comments on commit 9e50fce

Please sign in to comment.