jQuery 中的状态管理是什么?

What is state management in jQuery?

jQuery UI Widget Factory中:

The jQuery UI Widget Factory is an extensible base on which all of jQuery UI's widgets are built. Using the widget factory to build a plugin provides conveniences for state management, as well as conventions for common tasks like exposing plugin methods and changing options after instantiation.

谁能用简单的语言解释一下(最好有一个例子),在这种情况下状态管理是什么意思?我知道的状态管理是浏览器历史state management(可能使用HTML5历史API,或者history.js)但是我没有看到它和[=23=之间有任何关系] UI Widget Factory 用途。

感谢您的帮助。

来自文档的 "Why Use the Widget Factory?" 部分:

Stateless vs. Stateful Plugins

Most jQuery plugins are stateless; they perform some action and their job is done. For example, if you set the text of an element using .text( "hello" ), there is no setup phase and the result is always the same. For these types of plugins, it makes sense to just extend jQuery's prototype.

However, some plugins are stateful; they have full life cycles, maintain state, and react to changes. These plugins require a lot of code dedicated to initialization and state management (and sometimes destruction). This results in a lot of boilerplate for building stateful plugins. Even worse, each plugin author may manage life cycles and state differently, resulting in different API styles for different plugins. The widget factory aims to solve both problems, removing the boilerplate and creating a consistent API across plugins.