Fusion
Fusion copied to clipboard
Scopes + memory groundwork
Partially implements #269. This PR introduces some groundwork for future memory management changes, and introduces basic support for the 'scoped' memory management pattern (https://fluff.blog/2023/08/30/the-next-ten-years-beyond-maids.html, https://github.com/dphfox/scoped).
- [x] Move all memory management utilities into a dedicated Memory folder
- [x] Rename
cleanuptodoCleanupfor consistency (#237) - [x] Add destroy methods to all objects
- [x] Add type information for destroy methods on objects
- [x] Add cleanup tables as first parameters to all constructors
- [x] Warn when scopes mismatch for things expected to have the same lifetime
- [x] Implement
scoped()syntax sugar for cleanup tables w/ constructor methods - [x] Generate inner scopes for state objects
- [x] Ensure type checking mostly passes for additions, and note where it does not currently work so it can be targeted for future PRs
- [x] Update unit tests
- [ ] Update API reference
- [x] Restructure API reference to separate types from members
- [x] Fix Errors page not rendering
- [x] Remove old errors from Errors page
- [x] Update formatting of API pages
- [ ] Create or update documentation pages
- [ ] Commonly Used
- [ ] General
- [ ] Errors
- [x] cannotAssignProperty
- [x] cannotConnectChange
- [x] cannotConnectEvent
- [x] cannotCreateClass
- [ ] callbackError
- [ ] forKeyCollision
- [ ] forProcessorError
- [ ] invalidChangeHandler
- [ ] invalidAttributeChangeHandler
- [ ] invalidEventHandler
- [ ] invalidPropertyType
- [ ] invalidRefType
- [ ] invalidOutType
- [ ] invalidAttributeOutType
- [ ] invalidOutProperty
- [ ] invalidSpringDamping
- [ ] invalidSpringSpeed
- [ ] mistypedSpringDamping
- [ ] mistypedSpringSpeed
- [ ] mistypedTweenInfo
- [ ] noTaskScheduler
- [ ] springTypeMismatch
- [ ] stateGetWasRemoved
- [ ] unknownMessage
- [ ] unrecognisedChildType
- [ ] unrecognisedPropertyKey
- [ ] unrecognisedPropertyStage
- [x] Types
- [x] Version
- [x] Contextual
- [x] Members
- [x] version
- [x] Contextual
- [ ] Errors
- [x] Memory
- [x] Types
- [x] Scope
- [x] ScopedObject
- [x] Task
- [x] Members
- [x] deriveScope
- [x] doCleanup
- [x] scoped
- [x] Types
- [x] State
- [x] Types
- [x] CanBeState
- [x] Computed
- [x] Dependency
- [x] Dependent
- [x] For
- [x] Observer
- [x] StateObject
- [x] Use
- [x] Value
- [x] Members
- [x] Computed
- [x] ForKeys
- [x] ForPairs
- [x] ForValues
- [x] Observer
- [x] peek
- [x] Value
- [x] Types
- [x] Roblox
- [x] Types
- [x] Child
- [x] PropertyTable
- [x] SpecialKey
- [x] Members
- [x] Attribute
- [x] AttributeChange
- [x] AttributeOut
- [x] Children
- [x] Hydrate
- [x] New
- [x] OnChange
- [x] OnEvent
- [x] Out
- [x] Ref
- [x] Types
- [ ] Animation
- [ ] Types
- [ ] Animatable
- [ ] Spring
- [ ] Tween
- [ ] Members
- [ ] Spring
- [ ] Tween
- [ ] Types
- [x] Update examples
- [x] Update tutorials
- [x] Write dedicated scopes section before introducing objects
- [x] Update all code examples to use scopes
I think it'd be useful to pull in concepts from #220 for the backend implementation of the For objects. This won't be exposed to users yet - and it probably wouldn't be the final implementation because of #205 - but it'll be useful for tidying up those rat's nests and ensuring they have consistent destruction and memory management.
Working on debugging the unified internal For implementation now.
Now disposing of unused processors at the right time :)
New For object implementations are now passing unit tests.
I'm running into issues with typechecking that seem hard to surmount. They might actually be bugs in Luau or the luau-lsp plugin.
I'm going to simply try and fix a decent amount of them that seem possible, and leave the rest in so that this can get out the door. I'll redistribute the type checking fixes to another issue/PR somewhere else.
Examples have now all been updated to use scope syntax, and also have more fully fleshed-out explanations to go along with it. Pleasantly, a lot of the code snippets are simpler now! That's partly thanks to scopes, but also a little bit thanks to improved coding conventions generally.
Since we're no longer pursuing additional API surface for the time being, this now fully closes #269.