Fusion
Fusion copied to clipboard
Create Delay objects
Implementation of #74. Value objects can be wrapped in a Delay object to have their state changes delayed. The problem proposed by the original issue can now be easily resolved.

Example usage:
local springGoal = Value(0)
local delayedSpringGoal = Delay(springGoal, 2) -- Delay state changes by 2 seconds
local spring = Spring(delayedSpringGoal, 5, 1)
New 'TextLabel' {
Size = Computed(function()
return UDim2.new(spring:get(), 0, 0.1, 0)
end)
}
springGoal:set(1)
This looks absolutely fantastic at first glance - thanks for this contribution!
I'll do a code review when I next have some time available :)
Seems like a nasty edge case exists here: consider
Delay(FollowerState, DurationState)
I don't think this is an edge case. This was mentioned in #74 as a possible problem but I actually specifically implemented it like this because logically it makes sense. The order that state is updated doesn't affect delay objects; the scheduler only cares about making sure they update after their duration has passed. It might also be possible to implement a way to toggle this behavior with an additional parameter to Delay() but I don't want to clutter the constructor too much.
After some thought, I definitely don't think this way of the Duration parameter as a state is the right direction. It is confusing and not all that useful. If a State is allowed for the duration at all, the behaviour should be that it delays to whatever the follower state was at [duration] time ago.
I'm considering rolling this into Fusion as part of 0.3's broader animation system overhauls. As such, I'm going to mark this PR as blocked for the time being as we work through the backlog of pull requests.
I plan to merge this in soon. :)
Closing this PR - but I plan to implement this alongside the rest of the animation changes, which will happen in a different branch. Thanks for the contributions; I'll make sure to refer back to this PR.