Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Clear "AtomList" and "AtomCollection" OnEnable #431

Open
peter-mills-dev opened this issue Sep 27, 2023 · 0 comments
Open

[FEATURE] Clear "AtomList" and "AtomCollection" OnEnable #431

peter-mills-dev opened this issue Sep 27, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@peter-mills-dev
Copy link

Is your feature request related to a problem? Please describe.
AtomList and AtomCollection don't have an option to clear on enable like the ValueList types.

Describe the solution you'd like
AtomList and AtomCollection should follow the same pattern as ValueLists and include a clear on enable option,
or AtomList and AtomCollection should follow the same pattern as atoms generally and be split into Variable and Constant variants.

Describe alternatives you've considered
Using an on start monohook to manually clear the Lists and Collections. This is unneeded overhead when other atom objects are able to initialize themselves as needed,

Create a copy of AtomList that is clearable outside of the atoms package. This is much more achievable for these types than other atoms, since they don't need to be recreated for each new atom type, but it is still duplication and makes upgrading and maintaining code harder.

Additional context
A simple implementation borrowed from BaseAtomValueList

        /// <summary>
        /// Whether the list should start cleared
        /// </summary>
        [SerializeField]
        protected bool _startCleared;
        
         void OnEnable()
        {
            if (Value == null) return;

            Value.Added += PropogateAdded;
            Value.Removed += PropogateRemoved;
            Value.Cleared += PropogateCleared;
            
            if (_startCleared)
            {
                _value.Clear();
            }
        }
@peter-mills-dev peter-mills-dev added the enhancement New feature or request label Sep 27, 2023
@soraphis soraphis changed the title [FEATURE] [FEATURE] Clear "AtomList" and "AtomCollection" OnEnable Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant