Skip to content

Conversation

@emyfops
Copy link
Collaborator

@emyfops emyfops commented Feb 14, 2025

This pull request changes the AbstractSetting event subscribers such as onValueChanged, onValueSet and others to facilitate subscription without having to wrap it in an apply block

Before:

private val mesh by setting("Mesh", true, "Connect similar adjacent blocks").apply { onValueSet(::rebuildMesh) }

After

private val mesh by setting("Mesh", true, "Connect similar adjacent blocks").onValueSet(::rebuildMesh)

Instead, we call apply in the event subscription event

fun onValueSet(block: (from: T, to: T) -> Unit) = apply {
    listeners.add(ValueListener(false, block))
}

@github-actions github-actions bot added triage Requires labelling or review 1.20 labels Feb 14, 2025
@emyfops emyfops removed the triage Requires labelling or review label Feb 15, 2025
@emyfops
Copy link
Collaborator Author

emyfops commented Feb 15, 2025

Tested, working

@emyfops emyfops merged commit ca435be into master Feb 15, 2025
3 checks passed
@emyfops emyfops deleted the refactor/settings branch February 15, 2025 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants