isAnEditable method

bool isAnEditable(
  1. Object? anyObject
)

Check if an object is an editable.

This check is performed in the class, its not passed through to the Aloha API, Aloha uses javascript object comparison which is not robust, we can better do this ourselves.

Implementation

bool isAnEditable(Object? anyObject) {
  if (!_ready) throw AlohaException(AlohaException.notReady);

  /* If we are an AlohaEditable then we are an editable */
  if (anyObject.runtimeType.toString() == 'AlohaEditable') return true;

  /* We must at least be a JsObject object to be an editable */
  if (anyObject.runtimeType.toString() != 'JsObject') return false;

  /* Check if the object is in the editables list */
  final int length = _alohaContext['editables'].length;
  final jsEditableList = _alohaContext['editables'];
  for (var i = 0; i < length; i++) {
    if (anyObject == _alohaContext[jsEditableList[i]]) return true;
  }

  return false;
}