Kylin/Fluent/qml/EventBus.qml
2024-08-31 12:32:26 +08:00

25 lines
509 B
QML

pragma Singleton
import QtQuick
QtObject {
property var events: []
function register(event){
events.push(event)
}
function unregister(event){
var index = events.indexOf(event)
if (index !== -1) {
events.splice(index, 1)
}
}
function post(name,data = {}){
for(var i =0 ;i< events.length; i++){
var item = events[i]
if(item.name === name){
item.triggered(data)
}
}
}
}