forked from siyuan-note/eventbus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventbus.go
79 lines (68 loc) · 2.78 KB
/
eventbus.go
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// EventBus - Event Bus for SiYuan.
// Copyright (c) 2022-present, b3log.org
//
// EventBus is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
// http://license.coscl.org.cn/MulanPSL2
//
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
//
// See the Mulan PSL v2 for more details.
package eventbus
import "github.com/asaskevich/EventBus"
var bus = EventBus.New()
func Publish(topic string, arg ...interface{}) {
bus.Publish(topic, arg...)
}
func Subscribe(topic string, handler interface{}) error {
return bus.Subscribe(topic, handler)
}
// 消息推送事件。
const (
CtxPushMsg = "pushMsg"
CtxPushMsgToProgress = iota
CtxPushMsgToStatusBar
CtxPushMsgToStatusBarAndProgress
)
// 数据库索引事件。
const (
EvtSQLInsertBlocks = "sql.insert.blocks"
EvtSQLInsertBlocksFTS = "sql.insert.blocks_fts"
EvtSQLDeleteBlocks = "sql.delete.blocks"
EvtSQLInsertHistory = "sql.insert.history"
)
// 数据仓库本地事件。
const (
EvtCheckoutBeforeWalkData = "repo.checkout.beforeWalkData"
EvtCheckoutWalkData = "repo.checkout.walkData"
EvtCheckoutUpsertFiles = "repo.checkout.upsertFiles"
EvtCheckoutUpsertFile = "repo.checkout.upsertFile"
EvtCheckoutRemoveFiles = "repo.checkout.removeFiles"
EvtCheckoutRemoveFile = "repo.checkout.removeFile"
EvtIndexBeforeWalkData = "repo.index.beforeWalkData"
EvtIndexWalkData = "repo.index.walkData"
EvtIndexBeforeGetLatestFiles = "repo.index.beforeGetLatestFiles"
EvtIndexGetLatestFile = "repo.index.getLatestFile"
EvtIndexUpsertFiles = "repo.index.upsertFiles"
EvtIndexUpsertFile = "repo.index.upsertFile"
)
// 数据仓库云端同步事件。
const (
EvtCloudLock = "repo.cloudLock"
EvtCloudUnlock = "repo.cloudUnlock"
EvtCloudBeforeUploadIndex = "repo.cloudBeforeUploadIndex"
EvtCloudBeforeUploadFiles = "repo.cloudBeforeUploadFiles"
EvtCloudBeforeUploadFile = "repo.cloudBeforeUploadFile"
EvtCloudBeforeUploadChunks = "repo.cloudBeforeUploadChunks"
EvtCloudBeforeUploadChunk = "repo.cloudBeforeUploadChunk"
EvtCloudBeforeDownloadIndex = "repo.cloudBeforeDownloadIndex"
EvtCloudBeforeDownloadFiles = "repo.cloudBeforeDownloadFiles"
EvtCloudBeforeDownloadFile = "repo.cloudBeforeDownloadFile"
EvtCloudBeforeDownloadChunks = "repo.cloudBeforeDownloadChunks"
EvtCloudBeforeDownloadChunk = "repo.cloudBeforeDownloadChunk"
EvtCloudBeforeDownloadRef = "repo.cloudBeforeDownloadRef"
EvtCloudBeforeUploadRef = "repo.cloudBeforeUploadRef"
)