{"id":13429399,"url":"https://github.com/dotnet/Comet","last_synced_at":"2025-03-16T03:31:31.313Z","repository":{"id":37389739,"uuid":"192122815","full_name":"dotnet/Comet","owner":"dotnet","description":"Comet is an MVU UIToolkit written in C#","archived":false,"fork":false,"pushed_at":"2024-09-05T18:49:19.000Z","size":11442,"stargazers_count":1654,"open_issues_count":55,"forks_count":117,"subscribers_count":69,"default_branch":"dev","last_synced_at":"2024-10-29T15:17:52.414Z","etag":null,"topics":[],"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/dotnet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE-OF-CONDUCT.md","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":"2019-06-15T20:50:46.000Z","updated_at":"2024-10-29T08:57:34.000Z","dependencies_parsed_at":"2023-01-23T01:16:37.500Z","dependency_job_id":"3933ce98-14b1-48a1-8cc4-cf9fa900d320","html_url":"https://github.com/dotnet/Comet","commit_stats":{"total_commits":1903,"total_committers":38,"mean_commits":"50.078947368421055","dds":0.2753547031003678,"last_synced_commit":"9526724f12478d972ecc33354ba335e57aef20b3"},"previous_names":["clancey/hotui","clancey/comet"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet%2FComet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet%2FComet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet%2FComet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet%2FComet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotnet","download_url":"https://codeload.github.com/dotnet/Comet/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243437965,"owners_count":20290864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-07-31T02:00:36.379Z","updated_at":"2025-03-16T03:31:30.491Z","avatar_url":"https://github.com/dotnet.png","language":"C#","funding_links":[],"categories":["Mobile","others"],"sub_categories":[],"readme":"\u003cimg src=\"https://repobeats.axiom.co/api/embed/f917a77cbbdeee19b87fa1f2f932895d1df18b56.svg\" /\u003e\n\n# Comet ☄️\n\n[![dev-build](https://github.com/dotnet/Comet/actions/workflows/dev.yml/badge.svg)](https://github.com/dotnet/Comet/actions/workflows/dev.yml)  [![Clancey.Comet on fuget.org](https://www.fuget.org/packages/Clancey.Comet/badge.svg)](https://www.fuget.org/packages/Clancey.Comet)\n[Chat on Discord](https://discord.gg/7Ms7ptM)\n\n\nWhat is Comet? Comet is a modern way of writing cross-platform UIs. Based on [.NET MAUI](https://docs.microsoft.com/en-us/dotnet/maui/what-is-maui), it follows the Model View Update (MVU) pattern and magically databinds for you!\n\nWatch this video to get a preview of the developer experience:\n\n[![Video Demo](http://img.youtube.com/vi/-Ieg9UadN8s/0.jpg)](http://www.youtube.com/watch?v=-Ieg9UadN8s)\n\n## Getting Started\n\nWhen you're ready to take a ride on the Comet, head over to the wiki and follow the [Getting Started](https://github.com/Clancey/Comet/wiki/Getting-Started) guide.\n\n## Key Concepts\n\nComet is based on the MVU architecture:\n\n![MVU pattern](art/mvu-pattern.png)\n\n`View` is a screen. Views have a `Body` method that you can assign either by using an attribute `[Body]`:\n\n``` cs\npublic class MyPage : View {\n    [Body]\n    View body () =\u003e new Text(\"Hello World\");\n}\n```\n\nOr manually from your constructor:\n\n``` cs\npublic class MyPage : View {\n    public MyPage() {\n        Body = body;\n    }\n    View body () =\u003e new Text(\"Hello World\");\n}\n```\n\n## Hot Reload\n\nUsing Hot Reload is the fastest way to develop your user interface.\n\nThe setup is simple and only requires a few steps:\n1. Install the Visual Studio extension `Comet.Reload` from [Releases](https://github.com/dotnet/Comet/releases) (or [Comet for .NET Mobile](https://marketplace.visualstudio.com/items?itemName=Clancey.comet-debug) if you use Visual Studio Code)\n2. Install the [Comet project template](https://www.nuget.org/packages/Clancey.Comet.Templates.Multiplatform) available on NuGet.\n3. Add this short snippet to your `AppDelegate.cs` and/or `MainActivity.cs`, or equivalent.\n\n``` cs\n#if DEBUG\nComet.Reload.Init();\n#endif\n```\n\n See the sample projects [here](https://github.com/dotnet/Comet/tree/dev/sample) for examples.\n\n## State\n\nAs of right now there are two supported ways to add state.\n\n### 1. Simple data types like int, bool?\n\nJust add a `State\u003cT\u003e` field to your View\n\n``` cs\nclass MyPage : View {\n    readonly State\u003cint\u003e clickCount = 1;\n}\n```\n\n`View` is state aware. When the state changes, databinding will automatically update, or rebuild the view as needed.\n\n### 2. Do you want to use more complex data types?\n\nYou can either implement [INotifyPropertyRead](https://github.com/Clancey/Comet/blob/master/src/Comet/BindingObject.cs#L13) or you can use [BindingObject](https://github.com/Clancey/Comet/blob/master/src/Comet/BindingObject.cs) to make it even simpler.\n\nAdd it as a Field/Property, and add the `[State]` attribute!\n\n\n``` cs\npublic class MainPage : View {\n    class MyBindingObject : BindingObject {\n        public bool CanEdit {\n            get =\u003e GetProperty\u003cbool\u003e ();\n            set =\u003e SetProperty (value);\n        }\n        public string Text {\n            get =\u003e GetProperty\u003cstring\u003e ();\n            set =\u003e SetProperty (value);\n        }\n    }\n\n    [State]\n    readonly MyBindingObject state;\n}\n\n```\n\n`INotifyPropertyRead` is just like `INotifyPropertyChanged`. Just call `PropertyRead` whenever a property getter is called. And `PropertyChanged` whenever a property value changes.\n\n### How do I use the State?\n\nSimply update the stateful value and the framework handles the rest.\n\n``` cs\npublic class MyPage : View {\n\n    readonly State\u003cint\u003e clickCount = 1;\n    readonly State\u003cstring\u003e text = \"Hello World\";\n\n    public MyPage() {\n        Body = () =\u003e new VStack {\n            new Text (text),\n            new Button(\"Update Text\", () =\u003e state.Text = $\"Click Count: {clickCount.Value++}\")\n        };\n\n    }\n}\n```\n\nThat is all!, now when the text changes everything updates.\n\n### What if I want to format my value without an extra state property?\n\nWhile `new Button(\"Update Text\", () =\u003e state.Text = $\"Click Count: {clickCount.Value++}\" )` works, it isn't efficient.\n\nInstead, use `new Text(()=\u003e $\"Click Count: {clickCount}\")`.\n\n``` cs\npublic class MyPage : View {\n\n    readonly State\u003cint\u003e clickCount = new State\u003cint\u003e (1);\n\n    public MyPage() {\n        Body = () =\u003e new VStack {\n            new Text (() =\u003e $\"Click Count: {clickCount}\"),\n            new Button(\"Update Text\", () =\u003e {\n                clickCount.Value++;\n            }\n        };\n    }\n}\n\n```\n\n\n## What platforms are supported?\n\nComet is developed on top of .NET MAUI handlers, providing its own implementation for interfaces such as `Microsoft.Maui.IButton` and other controls. Any platform supported by .NET MAUI can be targeted:\n\n* Windows\n* Android\n* iOS\n* macOS\n* Blazor\n\nNon-MAUI application models, such as UWP or WPF, are not supported.\n\n# Disclaimer\n\nComet is a **proof of concept**. There is **no** official support. Use at your own risk.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet%2FComet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotnet%2FComet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet%2FComet/lists"}