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

20 lines
358 B
GDScript3
Raw Permalink Normal View History

2024-01-23 18:48:13 +02:00
extends RefCounted
2024-03-17 01:14:31 +02:00
## A group of proxies that will be updated when one of them is updated
2024-01-23 18:48:13 +02:00
class_name ProxyGroup
var proxies = []
func proxy(_get: Callable, _set: Callable):
var _proxy
_proxy = Proxy.new(_get, func(value):
_set.call(value)
for p in proxies:
if p != _proxy:
2024-03-21 14:29:10 +02:00
p.on_set.emit(p.value)
2024-01-23 18:48:13 +02:00
)
proxies.append(_proxy)
return _proxy