Skip to content

Commit

Permalink
feat(capacitor): extract nextId()
Browse files Browse the repository at this point in the history
  • Loading branch information
ratson committed Apr 16, 2021
1 parent 3a2b568 commit 6d49548
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/capacitor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,22 @@ type MobileAdOptions = { adUnitId: string }

class MobileAd {
private static allAds: { [s: number]: MobileAd } = {}
private static _counter = 1
private static idCounter = 0

public readonly adUnitId: string
public readonly id: number

constructor({ adUnitId }: MobileAdOptions) {
this.adUnitId = adUnitId

this.id = MobileAd._counter++
this.id = MobileAd.nextId()
MobileAd.allAds[this.id] = this
}

private static nextId() {
MobileAd.idCounter += 1
return MobileAd.idCounter
}
}

class BannerAd extends MobileAd {
Expand Down

0 comments on commit 6d49548

Please sign in to comment.