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
Using vide 0.3.1, latest version on wally
Effects seem to always run twice when a source changes
I assumed maybe reads also trigger effects, but that's not the cause:
The text was updated successfully, but these errors were encountered:
This is a feature of Vide's Strict Mode to encourage writing pure effects that clean up properly. It's automatically enabled in Roblox Studio and defaults to false in production.
If you need your code to run once in an effect (and you don't want to disable strict mode), one method is to defer the code and allow subsequent effect calls to cancel it:
Vide.effect(function()
localconnection=RunService.Heartbeat:Once(function()
-- code here runs max once per frameend)
cleanup(connection)
end)
You can also compare the current and previous state tracked by an effect and check whether that changed:
vide.effect(function(previous)
localcurrent=state()
ifcurrent~=previousthen-- code here only runs when state() changedendreturncurrentend, state())
Using vide 0.3.1, latest version on wally
Effects seem to always run twice when a source changes
I assumed maybe reads also trigger effects, but that's not the cause:
The text was updated successfully, but these errors were encountered: