-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.ts
30 lines (24 loc) · 958 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { DotBit, BitAccount, BitPluginBase, sleep } from 'dotbit'
import './types'
import { version } from './version'
export class BitPluginTemplate implements BitPluginBase {
version = version
name = 'BitPluginTemplate'
onInstall (dotbit: DotBit) {
console.log('This function will be invoked when plugin installed, you can add some methods to DotBit like the code below:')
dotbit.flyAccount = function (this: DotBit, account: string) {
const bitAccount = this.account(account)
return bitAccount.fly().then(word => word + ' to sky')
}
}
onUninstall (dotbit: DotBit) {
console.log('This function will be invoked when plugin uninstalled')
}
onInitAccount (bitAccount: BitAccount) {
console.log('This function will be invoked when .bit account initialized')
bitAccount.fly = async function (this: BitAccount): Promise<string> {
await sleep(100)
return `${this.account} is flying`
}
}
}