{"id":26550128,"url":"https://github.com/swingcosmic/reactivesharp","last_synced_at":"2026-04-13T16:04:02.055Z","repository":{"id":238150132,"uuid":"795110183","full_name":"SwingCosmic/ReactiveSharp","owner":"SwingCosmic","description":"像前端一样在.NET中简单地使用响应式数据","archived":false,"fork":false,"pushed_at":"2024-07-14T13:52:36.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T07:33:01.813Z","etag":null,"topics":["aot-compatible","csharp","dotnet","reactive-programming"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SwingCosmic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-02T15:50:27.000Z","updated_at":"2024-07-14T16:04:29.000Z","dependencies_parsed_at":"2024-05-04T16:30:39.521Z","dependency_job_id":"8fe1270e-108e-4c38-9052-c26ab6bcdb9a","html_url":"https://github.com/SwingCosmic/ReactiveSharp","commit_stats":null,"previous_names":["swingcosmic/reactivesharp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SwingCosmic/ReactiveSharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwingCosmic%2FReactiveSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwingCosmic%2FReactiveSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwingCosmic%2FReactiveSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwingCosmic%2FReactiveSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SwingCosmic","download_url":"https://codeload.github.com/SwingCosmic/ReactiveSharp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwingCosmic%2FReactiveSharp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31759567,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T15:25:13.801Z","status":"ssl_error","status_checked_at":"2026-04-13T15:25:09.162Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aot-compatible","csharp","dotnet","reactive-programming"],"created_at":"2025-03-22T07:30:26.910Z","updated_at":"2026-04-13T16:04:02.027Z","avatar_url":"https://github.com/SwingCosmic.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ReactiveSharp\n\n像前端一样在.NET中简单地使用响应式数据。\n\n* 实现了`IObservable\u003cT\u003e`，因此可以与`Rx.NET`配合使用\n* 实现了`INotifyPropertyChanged`等接口，可以与`WPF`等传统数据绑定一起工作\n* 支持从.NET Standard 2.1(Unity)到.NET8+，且针对.NET新版本功能做了不同的优化\n* 依赖反射和动态代码的部分较少，可以在.NET Native AOT或者Unity IL2CPP等AOT环境下运行，只有少数方法不能使用。如果使用.NET7+，可以从方法的注解上看出哪些在AOT下会出现问题\n\n## 重要的类型\n\n* IReadOnlyRef\u0026lt;T\u0026gt;\n表示一个只读的响应式值的引用\n\n* IRef\u0026lt;T\u0026gt;\n表示一个可写入的响应式值的引用\n\n以上类型可以通过创建响应式对象的实例，或者通过`RefHelpers`的工具方法生成\n\n* RefHelpers\n提供了大量工具方法用于封装现有对象为响应式对象，例如将类的一个属性封装为独立的`IRef\u003cT\u003e`，使其可以用于创建计算属性\n\n\n## 响应式对象\n\n### Ref\u0026lt;T\u0026gt;\n\n可读写的响应式对象引用，实现了`IRef\u003cT\u003e`\n\n相当于`vue`的`ShallowRef`，或者`@preact/signals`的`Signal`，对所引用的对象具有浅层响应式\n\n### Computed\u0026lt;T\u0026gt;\n\n只读的计算属性引用，仅当依赖变化时才会重新计算，实现了`IReadOnlyRef\u003cT\u003e`。\n计算属性可以依赖任何实现了`IReadOnlyRef\u003cT\u003e`接口的类型（包括其他计算属性）\n\n相当于`vue`的`Computed`，但是语法上更接近`react`的`useMemo`\n\n```csharp\nvar a = new Ref\u003cint\u003e(1);\nvar b = new Ref\u003cint\u003e(1);\n\nvar c = new Computed\u003cint, int, int\u003e(() =\u003e \n{\n  return a.Value + b.Value;\n}, a, b);\n\na.Value = 2;\n\nConsole.WriteLine(c.Value); // 3\n\n```\n\n### Effect\n提供一些方法监听依赖的变更并执行副作用，类似`vue`的`watch`。\n支持同步和异步的版本","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswingcosmic%2Freactivesharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswingcosmic%2Freactivesharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswingcosmic%2Freactivesharp/lists"}