Hi, so I found this wrapper snippet and was wondering if I can use it for 2 or more variables and if so, how. Thanks in advance
Snippet:
Hi, so I found this wrapper snippet and was wondering if I can use it for 2 or more variables and if so, how. Thanks in advance
Snippet:
You can just make the function take a tuple() as a param and pass extra data this way
event_wrapper(t:type, t2:type) := class:
ExtraData : t2
InFunction : type{func(:t, :t2):void}
ProxyFunction(T:t):void=
InFunction(T, ExtraData)
(S:subscribable(t)).SubscribeExtraData(InFunction:type{func(:t, :t2):void}, ExtraData:t2 where t:type, t2:type)<transacts>:cancelable=
Wrapper := event_wrapper(t, t2):
ExtraData := ExtraData
InFunction := InFunction
S.Subscribe(Wrapper.ProxyFunction)
test_device := class(creative_device):
@editable Button : button_device = button_device{}
OnBegin<override>()<suspends>:void=
Button.InteractedWithEvent.SubscribeExtraData(OnButtonClicked, (0, "String"))
OnButtonClicked(Agent:agent, ExtraParams:tuple(int, string)):void=
I := ExtraParams(0)
S := ExtraParams(1)
Print("Button Clicked {I} {S}")
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.