Matt-MX / KtPaperGui

Declarative GUI focused library for PaperMC. Made for personal use but open source enjoy! :)
Apache License 2.0
25 stars 5 forks source link

Signals changes #34

Open Matt-MX opened 3 months ago

Matt-MX commented 3 months ago

Signals should be modified to be easily implemented into other components the library provides.

This includes scoreboards

val foo = signal("something")

scoreboard(!"&cTest Signal") {
    +!"&fValue: &e${foo()}"
}

val fooArg by stringArgument()
("setFoo" / fooArg).runs<Player> {
    foo setTo fooArg()
}

Additionally the RefreshBlock should be abstracted to be used in other components.


val ping by refresh { player.ping }

scoreboard(!"&fYour ping") {
    +!"&fPing: &7${ping}"
    +!"&cThis line won't update since we don't change"
}
Matt-MX commented 3 months ago

By this I mean that the Signal class should not have a singular owner object, and should instead be available anywhere in the program.

When used in a block that implements the SignalListener interface, we should then mark this as a dependency for this Signal instance.

We also will need a way to remove these dependencies when they are no longer required otherwise we'll have a memory leak 😱