Title: [Article] How to write custom event listener for C# changes in React · Issue #8 · ReactUnity/reactunity.github.io · GitHub
Open Graph Title: [Article] How to write custom event listener for C# changes in React · Issue #8 · ReactUnity/reactunity.github.io
X Title: [Article] How to write custom event listener for C# changes in React · Issue #8 · ReactUnity/reactunity.github.io
Description: Example code to put in the article C# public Action AddKeyPressListener(object callback) { var cb = ReactUnity.Helpers.Callback.From(callback); Action
Open Graph Description: Example code to put in the article C# public Action AddKeyPressListener(object callback) { var cb = ReactUnity.Helpers.Callback.From(callback); Action
X Description: Example code to put in the article C# public Action AddKeyPressListener(object callback) { var cb = ReactUnity.Helpers.Callback.From(callback); Action<string> listener = null; listener = (val...
Opengraph URL: https://github.com/ReactUnity/reactunity.github.io/issues/8
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Article] How to write custom event listener for C# changes in React","articleBody":"Example code to put in the article\r\n\r\nC#\r\n```\r\n public Action AddKeyPressListener(object callback)\r\n {\r\n var cb = ReactUnity.Helpers.Callback.From(callback);\r\n Action\u003cstring> listener = null;\r\n listener = (val) => {\r\n if (cb?.callback == null) // Check if we lost reference to cb, if so unsubscribe because we probably lost handle.\r\n {\r\n OnKeyPress -= listener;\r\n return;\r\n }\r\n cb.Call(val);\r\n }\r\n\r\n OnKeyPress += listener;\r\n\r\n return () => OnKeyPress -= listener;\r\n }\r\n```\r\n\r\nTSX\r\n```\r\n const [key, setKey] = useState(\"\");\r\n useEffect(() => { \r\n const unsubscribe = Global.Instance.AddKeyPressListener((input: string) => {\r\n setKey(input);\r\n });\r\n // Get current value before hook is called\r\n const input= Global.Instance.LastKeyPressed;\r\n setKey(input);\r\n return () => unsubscribe();\r\n }, []);\r\n\r\n```","author":{"url":"https://github.com/Muchaszewski","@type":"Person","name":"Muchaszewski"},"datePublished":"2022-12-06T10:56:02Z","url":"https://github.com/ReactUnity/reactunity.github.io/issues/8"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2a7dd2a3-9668-fa4d-624a-f20baa3c6088 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 878C:39D56F:9DB7FB:D0A6E9:6AF84F05 |
| html-safe-nonce | 9409c0842c30bb50e8ad2338c4092beaa511decbc620992a34999e8ab3ab227d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzhDOjM5RDU2Rjo5REI3RkI6RDBBNkU5OjZBRjg0RjA1IiwidmlzaXRvcl9pZCI6IjU5NjQyMjgwMDEyMDAwOTkwNzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0685df709e4ab452f22b9c57132aa0c950cf89dcc773ac9fbdb9cabe469a7ec7 |
| hovercard-subject-tag | issue:1478813524 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/ReactUnity/reactunity.github.io/8/issue_layout |
| twitter:image | https://opengraph.githubassets.com/36ffaae533b529df08e7a709f84bf27dfb605e812b7869f6bf3f025003abef19/ReactUnity/reactunity.github.io/issues/8 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/36ffaae533b529df08e7a709f84bf27dfb605e812b7869f6bf3f025003abef19/ReactUnity/reactunity.github.io/issues/8 |
| og:image:alt | Example code to put in the article C# public Action AddKeyPressListener(object callback) { var cb = ReactUnity.Helpers.Callback.From(callback); Action |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Muchaszewski |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5713ecd83001b2f55c3509fb7a292bf7d66d0f167c7ae87a9f7eaec5a52bf8db |
| turbo-cache-control | no-preview |
| go-import | github.com/ReactUnity/reactunity.github.io git https://github.com/ReactUnity/reactunity.github.io.git |
| octolytics-dimension-user_id | 62178684 |
| octolytics-dimension-user_login | ReactUnity |
| octolytics-dimension-repository_id | 247283033 |
| octolytics-dimension-repository_nwo | ReactUnity/reactunity.github.io |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 247283033 |
| octolytics-dimension-repository_network_root_nwo | ReactUnity/reactunity.github.io |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 653be32ff5c755082a4db662491bfbbcfc9112c1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width