You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
suggesting to allow two syntax approaches in PeachPie:
treat event as a fake object with add()and remove() methods: $x->e->add( function() {} ).
handle +=and -= operators: $x-> e += function () {}
event will be callable as well (the fake object will have __invoke method)
Note, remove of callables from .NET event might not work (since the instance of the delegate won't be the same), so the on() method should return an instance of a special class with "Dispose" or "Close" methods which would remove the delegate from the event as it's more common in other languages.
The text was updated successfully, but these errors were encountered:
Allow add/remove callable to the .NET/C#
event
for example having C# class
X
as below:suggesting to allow two syntax approaches in PeachPie:
event
as a fake object withadd()
andmethods:remove()
$x->e->add( function() {} )
.+=
andoperators:-=
$x-> e += function () {}
__invoke
method)Note,
remove
of callables from .NET event might not work (since the instance of the delegate won't be the same), so theon()
method should return an instance of a special class with "Dispose" or "Close" methods which would remove the delegate from theevent
as it's more common in other languages.The text was updated successfully, but these errors were encountered: