{"id":23045344,"url":"https://github.com/mykeels/intents","last_synced_at":"2025-08-14T23:31:48.206Z","repository":{"id":93602001,"uuid":"90643137","full_name":"mykeels/Intents","owner":"mykeels","description":"Handling deferred conditional execution in .NET such as social network LIKE button after login","archived":false,"fork":false,"pushed_at":"2017-05-11T10:38:02.000Z","size":408,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-01T07:45:46.470Z","etag":null,"topics":["asp-net","intents","web"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mykeels.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-05-08T15:21:41.000Z","updated_at":"2024-07-11T17:42:30.000Z","dependencies_parsed_at":"2023-03-12T02:00:34.353Z","dependency_job_id":null,"html_url":"https://github.com/mykeels/Intents","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mykeels/Intents","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mykeels%2FIntents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mykeels%2FIntents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mykeels%2FIntents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mykeels%2FIntents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mykeels","download_url":"https://codeload.github.com/mykeels/Intents/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mykeels%2FIntents/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270499987,"owners_count":24595149,"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","status":"online","status_checked_at":"2025-08-14T02:00:10.309Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["asp-net","intents","web"],"created_at":"2024-12-15T21:19:55.199Z","updated_at":"2025-08-14T23:31:48.193Z","avatar_url":"https://github.com/mykeels.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Intents\n\nEver wanted something like the Facebook LIKE button that defers the LIKE action till the user is authenticated? Or the [tweet button](https://twitter.com/intent/tweet) that saves the tweet and tweets it only after login?\n\nIf you build a web application with these kind of problems, you'd run into problems like these\n\nThat's what Intents helps you do.\n\n## Target Environment\n\n.NET Framework 4.5.2 (can be upgraded to support 4.6)\n\n## How it works\n\n- Intents are actions that are subscribed to, and executed only when triggered.\n  - Because they are actions, each Intent has a lambda expression or `Action\u003cTData\u003e` which defines the action.\n  - When an Intent is subcribed to, it is called a `UserIntent` and it contains data of type `TData` which is passed to the `Action\u003cTData\u003e` for execution.\n- When an Intent is registered, it becomes globally accessible via the `IntentManager.GetIntentManager()` singleton.\n- Intents can be saved in any storage system. One of my favorite is in Session Memory. You can implement the `Intents.IntentRepositoryContract` [interface](Intents/Interfaces/IntentRepositoryContract.cs) to use other storage media.\n\n## How to use (Web)\n\n- Add the `Intents` and `Intents.Web` Nuget packages to your project\n\n```\nInstall-Package Intents\nInstall-Package Intents.Web\n```\n\n- Import `Intents` and `Intents.Web` into your `global.asax.cs` class\n\n```cs\nusing Intents;\nusing Intents.Web;\n```\n\n- Register the Intents on Application Startup in your `global.asax.cs` [file](Intents.Mvc/Global.asax.cs)\n\n```cs\nprotected void Application_Start() {\n    IntentManager.GetIntentManager(new SessionRepository()).Register(new Intent\u003cstring\u003e()\n        {\n            name = \"tweet\",\n            trigger = \"login\",\n            action = (string tweetData) =\u003e\n            {\n                Console.WriteLine(\"Tweet: \" + tweetData);\n            }\n        });\n} \n//registers an intent to tweet something when \"login\" is triggered\n```\n\n- Create Storage for each user when a Session Starts\n\n```cs\nprotected void Session_Start()\n{\n    IntentManager.GetIntentManager().CreateSessionStorage();\n}\n```\n\n- To trigger our Intent when the user logins in execute the following statement when login is successful.\n\n```cs\nIntentManager.GetIntentManager().Trigger(\"login\");\n```\n\nThis will trigger all \"login\" intents the user has subscribed to. But how does the user subscribe to Intents?\n\n- To subscribe to intents, the `IntentManager` class has an `AddIntentData` method that handles this.\n\n```cs\n IntentManager.GetIntentManager().AddIntentData\u003cstring\u003e(\"login\", \"tweet\", \"Hello @MBuhari ... Nigeria supports you :p\");\n```\n\n- The `Intents.Web` library also comes with an `IntentsController.cs` [class](Intents.Web/IntentsController.cs) which exposes Mvc JsonResult endpoints with which users can manipulate their Intents via Http Requests.\n\n  It includes the following endpoints:\n\n    - Subscribe (POST or GET)\n    \n    Creates a new subscription to a registered Intent\n      \n      - trigger (string)\n      - name (string)\n      - data (stringified JSON data)\n      - redirectUri (string) (optional)\n   \n   - Trigger (GET)\n    \n    Triggers all Intents with a particular \"trigger\" attribute value\n      \n      - trigger (string)\n    \n   \n   - GetIntents (GET)\n    \n    Lists all Intents registered on the system\n   \n   - GetUserIntents (GET)\n    \n    Lists all user subscriptions to Intents\n\n- Lean back and watch those Intents fly ... :D\n\n## Author(s)\n\n- Ikechi Michael I.\n\n## License\n\nThis project is licensed under the Apache License","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmykeels%2Fintents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmykeels%2Fintents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmykeels%2Fintents/lists"}