8000 [FEATURE] Clear "AtomList" and "AtomCollection" OnEnable · Issue #431 · unity-atoms/unity-atoms · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[FEATURE] Clear "AtomList" and "AtomCollection" OnEnable #431
Open
@peter-mills-dev

Description

@peter-mills-dev

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();
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0