kbin-mod-options; v0.3.0 - Now with observers!
kbin-mod-options; v0.3.0 - Now with observers!
![](https://sacredori.net/media/71/68/716811d3b94ecb00d0b67c3528f0b1bca02e8f17e3d7c151614a30d3b6222e13.gif?format=webp&thumbnail=128)
![](https://sacredori.net/media/71/68/716811d3b94ecb00d0b67c3528f0b1bca02e8f17e3d7c151614a30d3b6222e13.gif?format=webp)
Creating a new thread as I've moved instances and can no longer update the old one. Sorry about that!
kbin-mod-options
Description
The purpose of this script is to allow mod authors to more easily implement settings and features. Only new feature notes will be included in this document. To view usage, please refer to the README.
Patch Notes
-
0.1.0 - Initial Release
-
0.2.0 - Breaking change. By default, settings will be collapsed as a drawer.
- 0.2.2 - Compatibility fix for KUP (Kbin Usability Pack) 0.2.1+.
- 0.2.3 - Style changes + animations.
- 0.2.4 - Bug-fix for Kbin/kbin-core#666.
-
0.3.0 - New feature: Observers!
Observer
This is for making infinite scroll support easier for mod creators and not an actual setting module.
kmoCreateObserver({<funcToCall: yourFunctionNameHere>[, nodeType: 'id'][, nodeToWatch: 'content'][, watchSubtree: false]});
NOTE: You're passing an object here that allows for named arguments. Please review example closely.
- funcToCall - required
- nodeType - optional
- nodeToWatch - optional
- watchSubtree - optional
Example
// Create observer for main content feed.
cont myObserver = kmoCreateObserver({funcToCall: updateNewContent});
// Example function
function updateNewContent() {
// Do stuff here
}
// Stop observing, maybe your addon is toggled off?
function shutdown() {
myObserver.disconnect();
}
// Maybe you want to watch perry.dev's subscription panel list
const mySubObserver = kmoCreateObserver({funcToCall: subUpdate, nodeType: 'class', nodeToWatch: 'subscription-list'});
// Example function
function subUpdate() {
// Do stuff here
}
// Stop observering - doesn't have to be in a function, but it makes life easier.
function shutdown() {
mySubObserver.disconnect();
}
0 comments