Opened 10 years ago

Last modified 7 years ago

#11502 confirmed New Feature

Synchronous calls of asynchronous methods causes errors — at Initial Version

Reported by: Piotrek Koszuliński Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Cc:

Description

See e.g. #11295. Calling editor.destroy() right after (or before it's completed) CKEDITOR.replace() or editor.setData() causes errors.

That's because developer has to care about calling methods when previous finished. There are callbacks and events which notify developer when action is completed, but it's his duty to find which method can be called when.

However, not every developer understand problems with asynchronous methods and not in every case it's easy to handle this. For example when editor is loaded in one tab of some UI component and user switches between tabs too quickly, destroy() may be called before editor fully initialises.

On the other hand, if editor's methods would take care of that (e.g. destroy() would wait until initialisation finished), then API would start to work unpredictably. Developer would never know if destroy() will be done immediately or if it's going to wait until something (setData, initialisation, etc.) ends. This may be even worse situation than the current one.

We could make even longer step and make all editor's methods asynchronous and e.g. based on promises. Then everything would be fine... if you understand all of this :D.

Therefore, instead of forcing developers to understand some not trivial concepts to do basic stuff we can simply clarify this in docs. But there still will be cases in which it will be hard to handle editor state (like the tabs case).

Opinions needed.

Change History (0)

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy