> For the complete documentation index, see [llms.txt](https://3440217568.gitbook.io/rxswift/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://3440217568.gitbook.io/rxswift/rxswift_core.md).

# 4. RxSwift 核心

这一章主要介绍 **RxSwift** 的核心内容：

![](/files/-MWlwRXpXtSJeLXeKnwi)

* [Observable](/rxswift/rxswift_core/observable.md) - 产生事件
* [Observer](/rxswift/rxswift_core/observer.md) - 响应事件
* [Operator](/rxswift/rxswift_core/operator.md) - 创建变化组合事件
* [Disposable](/rxswift/rxswift_core/disposable.md) - 管理绑定（订阅）的生命周期
* [Schedulers](/rxswift/rxswift_core/schedulers.md) - 线程队列调配

```swift
// Observable<String>
let text = usernameOutlet.rx.text.orEmpty.asObservable()

// Observable<Bool>
let passwordValid = text
    // Operator
    .map { $0.characters.count >= minimalUsernameLength }

// Observer<Bool>
let observer = passwordValidOutlet.rx.isHidden

// Disposable
let disposable = passwordValid
    // Scheduler 用于控制任务在那个线程队列运行
    .subscribeOn(MainScheduler.instance)
    .observeOn(MainScheduler.instance)
    .bind(to: observer)


...

// 取消绑定，你可以在退出页面时取消绑定
disposable.dispose()
```

下面几节会详细介绍这几个组件的功能和用法。

*ℹ️ 提示：这一章主要介绍一些偏理论方面的知识。你如果觉得阅读起来比较乏味的话，可以先**快速地浏览一遍**，了解 **RxSwift** 的核心组件大概有哪些内容。待以后遇到实际问题时，在回来查询。你可以直接跳到* [*更多例子*](/rxswift/more_demo.md) *章节，去了解如何应用 **RxSwift**。*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://3440217568.gitbook.io/rxswift/rxswift_core.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
