Kylin/Fluent/qml/EventBus.qml

25 lines
509 B
QML
Raw Permalink Normal View History

2024-08-31 12:32:26 +08:00
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)
}
}
}
}