Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Garrett Downs
committed
Mar 26, 2022
1 parent
f8fe89a
commit 9d99ec5
Showing
5 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export type MozWindow = Window & { | ||
MozActivity: any; | ||
} & any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { MozWindow } from '../models'; | ||
|
||
type Data = { | ||
name: string; | ||
data: { [key: string]: any }; | ||
}; | ||
|
||
export class Activity<TResult = any> { | ||
data: Data; | ||
|
||
constructor(data: Data) { | ||
this.data = data; | ||
} | ||
|
||
start(): Promise<TResult> { | ||
return new Promise((resolve, reject) => { | ||
const activity = new (window as MozWindow).MozActivity(this.data); | ||
|
||
activity.onsuccess = function () { | ||
resolve(this.result); | ||
}; | ||
|
||
activity.onerror = function () { | ||
reject(this.error); | ||
}; | ||
}); | ||
} | ||
} |