StateObserver
The StateObserver interface is a basic listening interface that monitors the Plugin state;
This interface is an internal interface. To get a specific instance, please access it through the Plugin.state property
import { statusBarPlugin } from "@plaoc/plugins";
statusBarPlugin.state.onChange((info) => {
// 当 state 发生变化的时候调用
})
Property
StateObserver.currentState
the current state object;
The value of the property is a State object;
The acquisition and setting of the state can be achieved through currentState; [Generally speaking, do not manually set the attribute value of currentState, this value will be automatically updated]
The property value is undefined until the initial update is complete
Method
is a Generator function;
Realized the reading and monitoring of plug-in status;
Once the state of the corresponding plug-in changes, it will trigger the listener set by the StateObserver.onChange() method;stop listening status
StateObserver.onChange(listener)
Add a listener; multiple listeners can be added through multiple calls;
StateObserver.getState([force_update])
Get the value of the current state
Event
- none
Platform Compatibility
Property/Method/Event | Android | IOS | Desktop-Dev | Desktop |
---|---|---|---|---|
currentState | ✅ | ✅ | ✅ | X |
jsonlines | ✅ | ✅ | ✅ | X |
stopObserve | ✅ | ✅ | ✅ | X |
onChange | ✅ | ✅ | ✅ | X |
getState | ✅ | ✅ | ✅ | X |