Skip to content

[feature] .isInitialized() instead of making developers figure out that they must use internal .el variable? #2407

Description

@hchiam

Is your feature request related to a problem? Please describe.
I found it unclear how to tell whether my object is initialized or not and only recently found that checking whether the object has mySortableObject?.el works, as opposed only checking if mySortableObject exists.

Describe the solution you'd like
Maybe some named helper function with a name like .isInitialized() or isUsingSortable()?

Describe alternatives you've considered
Otherwise it might be helpful to document that doing mySortableObject?.el is a better check than only mySortableObject (besides it being reported in this issue itself).

Additional context

let mySortableObject = null;
/* ... */
if (isUsingSortable()) {
  mySortableObject.destroy();
} else {
  mySortableObject = new Sortable(element, options);
}

function isUsingSortable() {
  return mySortableObject?.el;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions