immersive-home/app/lib/utils/proxy.gd

20 lines
428 B
GDScript3
Raw Permalink Normal View History

2023-11-28 00:46:05 +02:00
extends RefCounted
2024-03-17 01:14:31 +02:00
## A simple proxy class to allow for easy binding of a property to a function call.
2024-01-23 18:48:13 +02:00
class_name Proxy
signal on_set(new_value: Variant)
2023-11-28 00:46:05 +02:00
var gettable: Callable
var settable: Callable
func _init(gettable: Callable, settable: Callable):
self.gettable = gettable
self.settable = settable
var value: Variant:
get:
return gettable.call()
set(new_value):
2024-01-23 18:48:13 +02:00
settable.call(new_value)
on_set.emit(new_value)