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

Create new CollectionEntry class and add lifecycle hooks to Collections API #2046

Merged
merged 51 commits into from
Sep 26, 2024

Conversation

sebnitu
Copy link
Owner

@sebnitu sebnitu commented Sep 24, 2024

What changed?

The primary goal of this PR is to introduce the new CollectionEntry class used as the prototype of collection entries. This also introduces some new Collection API lifecycle hooks for both the root component (extended from Collection) and entries (extended from CollectionEntry).

New API

  • applySettings() (collection and entry) method that allows passing a configuration object to settings.
  • createEntry() (collection) method that returns an instantiation of the CollectionEntry class.

Lifecycle Hooks

Lifecycle hooks are applied using a new helper lifecycleHooks and is applied to mount/unmount and register/deregister actions. The following are the lifecycle hooks and the order that they are called:

On Mount:

  • beforeMount
  • entry.mount
    • entry.beforeMount
    • entry.afterMount
  • beforeRegister
  • entry.beforeRegister
  • Entry is added to collection.
  • entry.afterRegister
  • afterRegister
  • afterMount

On Unmount:

  • beforeUnmount
  • entry.unmount
    • entry.beforeUnmount
    • entry.afterUnmount
  • beforeDeregister
  • entry.beforeDeregister
  • Entry is removed from collection.
  • entry.afterDeregister
  • afterDeregister
  • afterUnmount

Additional changes

  • Core modules have been refactored and organized in a more logic way (utilities, helpers, etc).
  • Removed registerCollection
  • Removed deregisterCollection
  • getCustomProps now takes a collection entry as an argument.
  • getElement now returns null in final case.
  • transition no longer handles custom property fetching and instead requires some number value as the duration argument.
  • Added toMilliseconds which converts a string or number to milliseconds if possible.
  • Renamed updateGlobalState to setGlobalState.
  • All three component settings have been changed in the following ways:
    • Renamed selector[Component] to selector
    • Removed eventListeners
  • Close methods have been refactored to take id strings instead of optionally an HTML element or collections entry.
  • Renamed popover.cleanup() to popover.floatingCleanup()
  • Moved popover handleDocumentClick call into the open() function in an event type conditional.

@sebnitu sebnitu changed the title Create new Entry class and optimize Collections API Create new CollectionEntry class and optimize Collections API Sep 26, 2024
@sebnitu sebnitu changed the title Create new CollectionEntry class and optimize Collections API Create new CollectionEntry class and add lifecycle hooks to Collections API Sep 26, 2024
@sebnitu sebnitu marked this pull request as ready for review September 26, 2024 22:00
@sebnitu sebnitu merged commit e137d83 into next Sep 26, 2024
2 checks passed
@sebnitu sebnitu deleted the next-collections branch September 26, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant